feat: user error discrimination

This commit is contained in:
TrèsAbhi committed 2023-10-17 20:58:36 -05:00
1 parent f9e0584f00
commit 4b00e1342e
11 files changed
+49 -51

No files matched your search

+5 -5
View File
@@ -1,7 +1,7 @@
import { Region } from '../../constants/regions';
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
import { TanksStats } from '../../types/tanksStats';
import throwError from '../blitzkrieg/throwError';
import { UserError } from '../blitzkrieg/userError';
import fetchBlitz from './fetchWargaming';
export default async function getTankStats(region: Region, id: number) {
@@ -10,10 +10,10 @@ export default async function getTankStats(region: Region, id: number) {
);
if (tankStats[id] === null) {
throw throwError(
'No tank stats available',
"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', {
cause:
"This player doesn't have any stats for tanks available. This may not be the player you are looking for.",
});
}
return tankStats[id];