feat: improved error messages

This commit is contained in:
TrèsAbhi committed 2024-01-19 16:07:15 -06:00
1 parent 890a4d142b
commit 4c746cbb86
6 files changed
+32 -25

No files matched your search

+4 -4
View File
@@ -10,10 +10,10 @@ export default async function getTankStats(region: Region, id: number) {
);
if (tankStats[id] === null) {
throw new UserError('No tank stats available', {
cause:
"This player doesn't have any stats for tanks available. This may not be the player you are looking for.",
});
throw new UserError(
'No tank stats available',
"This player doesn't have any stats available. This may not be the player you are looking for.",
);
}
return tankStats[id];
+8 -6
View File
@@ -15,9 +15,10 @@ export default async function resolveTankId(tank: string | number) {
});
if (searchResult.length === 0) {
throw new UserError('Tank not found', {
cause: `Could not find tank by the name "${tank}".`,
});
throw new UserError(
'Tank not found',
`Could not find tank by the name "${tank}".`,
);
} else {
return searchResult[0].obj.id;
}
@@ -25,9 +26,10 @@ export default async function resolveTankId(tank: string | number) {
if ((await tankDefinitions)[number]) {
return number;
} else {
throw new UserError('Tank not found', {
cause: `Could not find tank by the ID "${number}".`,
});
throw new UserError(
'Tank not found',
`Could not find tank by the ID "${number}". Try typing the name of the tank instead of a number.`,
);
}
}
}