Skip to content

Commit

Permalink
merge catch blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Eisenwave committed Nov 9, 2024
1 parent 1d21681 commit 1504b78
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/components/moderation/moderation-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,16 +555,7 @@ export abstract class ModerationComponent extends BotComponent {
await this.reply_with_error(command, `User is already ${this.past_participle}`);
return;
}
let duration;
try {
duration = parse_nullable_duration(duration_string);
} catch (e) {
if (e instanceof ParseError) {
await this.reply_with_error(command, e.message);
return;
}
throw e;
}
const duration = parse_nullable_duration(duration_string);
const moderation: moderation_entry = {
...basic_moderation_info,
case_number: -1,
Expand Down Expand Up @@ -610,8 +601,12 @@ export abstract class ModerationComponent extends BotComponent {
],
});
} catch (e) {
await this.reply_with_error(command, `Error issuing ${this.type}`);
this.wheatley.critical_error(e);
if (e instanceof ParseError) {
await this.reply_with_error(command, e.message);
} else {
await this.reply_with_error(command, `Error issuing ${this.type}`);
this.wheatley.critical_error(e);
}
}
}

Expand Down

0 comments on commit 1504b78

Please sign in to comment.