mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: mature error handling system
This commit is contained in:
1 parent
1875f30cf5
commit
524edac615
23 files changed
+87
-87
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { CacheType, ChatInputCommandInteraction } from 'discord.js';
|
||||
import { go } from 'fuzzysort';
|
||||
import negativeEmbed from '../interaction/negativeEmbed.js';
|
||||
import errorWithCause from '../process/errorWithCause.js';
|
||||
import { TANKS, tankopedia } from './tankopedia.js';
|
||||
|
||||
export default async function resolveTankId(
|
||||
@@ -13,16 +13,10 @@ export default async function resolveTankId(
|
||||
const searchResult = go(tank, TANKS, { keys: ['name'], limit: 1 });
|
||||
|
||||
if (searchResult.length === 0) {
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
negativeEmbed(
|
||||
'Tank not found',
|
||||
`Could not find tank by the name "${tank}".`,
|
||||
),
|
||||
],
|
||||
});
|
||||
|
||||
throw new Error(`Tank not found by name "${tank}"`);
|
||||
throw errorWithCause(
|
||||
'Tank not found',
|
||||
`Could not find tank by the name "${tank}".`,
|
||||
);
|
||||
} else {
|
||||
return searchResult[0].obj.tank_id;
|
||||
}
|
||||
@@ -30,16 +24,10 @@ export default async function resolveTankId(
|
||||
if (tankopedia[number]) {
|
||||
return number;
|
||||
} else {
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
negativeEmbed(
|
||||
'Tank not found',
|
||||
`Could not find tank by the ID "${number}".`,
|
||||
),
|
||||
],
|
||||
});
|
||||
|
||||
throw new Error(`Tank not found by ID "${number}"`);
|
||||
throw errorWithCause(
|
||||
'Tank not found',
|
||||
`Could not find tank by the ID "${number}".`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user