Skip to content

Commit

Permalink
QuoteCommand: Wrap pull request creation in a try-catch
Browse files Browse the repository at this point in the history
The plugin will actually throw `Error`s for a lot of failure states,
which weren't caught before
  • Loading branch information
CommandMC authored and bgianfo committed Dec 19, 2023
1 parent 20a48a6 commit f557de7
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/commands/quoteCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,16 @@ export class QuoteCommand extends Command {
});

const commandIssuerNick = await this.getAuthorNick(guild, interaction.user);
const pullRequestNumber = await githubAPI.openFortunesPullRequest(
fortunes,
commandIssuerNick,
nickname
);
let pullRequestNumber;
try {
pullRequestNumber = await githubAPI.openFortunesPullRequest(
fortunes,
commandIssuerNick,
nickname
);
} catch (e) {
console.trace(e);
}

if (pullRequestNumber == undefined) {
const sadcaret = await getSadCaret(interaction);
Expand Down

0 comments on commit f557de7

Please sign in to comment.