Skip to content

Commit

Permalink
improve error message reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhouweling committed Nov 12, 2024
1 parent 16d565e commit 2c2e56d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/commands/stats/stats.mts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ export class StatsCommand extends BaseCommand {
await discordService.createMessage(thread.id, { embeds: [embed] });
}
} catch (error) {
console.error(error);

if (error instanceof Error && error.message === "Too many subrequests.") {
return;
}

await discordService.updateDeferredReply(interaction.token, {
content: `Failed to fetch (Channel: <#${channel}>, queue: ${queue.toString()}): ${error instanceof Error ? error.message : "unknown"}`,
});
Expand Down Expand Up @@ -215,6 +221,12 @@ export class StatsCommand extends BaseCommand {

await discordService.updateDeferredReply(interaction.token, { embeds: [embed] });
} catch (error) {
console.error(error);

if (error instanceof Error && error.message === "Too many subrequests.") {
return;
}

await discordService.updateDeferredReply(interaction.token, {
content: `Failed to fetch (match id: ${matchId}}): ${error instanceof Error ? error.message : "unknown"}`,
});
Expand Down
1 change: 1 addition & 0 deletions src/services/discord/discord.mts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export class DiscordService {
return { interaction: parsedInteraction, isValid: true };
} catch (error) {
console.error(error);

return { isValid: false, error: "Invalid JSON" };
}
}
Expand Down

0 comments on commit 2c2e56d

Please sign in to comment.