Skip to content

Commit

Permalink
feat: optimize error prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
Alvin-Liu committed Jun 18, 2023
1 parent af90405 commit 7d3c2c7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/command/start/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ class Start {
this.client = new OssUploader({ config });

this.run(argv).catch((error) => {
console.error(error);
console.log(chalk.red(error));
process.exit(-1);
});
}

async run({ max = 5 }: IStartCommandOptions) {
await this.client.initialClient();
try {
await this.client.initialClient();
} catch (error) {
return Promise.reject(error);
}

const files = this.client.findAllFiles();

Expand Down Expand Up @@ -59,7 +63,7 @@ class Start {
}
} catch (error) {
bar.stop();
throw error;
return Promise.reject(error);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/uploader/oss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class OSSUploader extends BaseUploader {

private initialCredentials(): ICredential {
if (!process.env.OSS_AK || !process.env.OSS_SK) {
new Error('AK and SK do not exist in environment variables')
throw new Error('OSS_AK and OSS_SK do not exist in environment variables')
}
return {
accessKeyId: (process.env.OSS_AK) as string,
Expand Down

0 comments on commit 7d3c2c7

Please sign in to comment.