mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59: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,4 +1,5 @@
|
||||
import { WargamingResponse } from '../../types/wargamingResponse.js';
|
||||
import errorWithCause from '../process/errorWithCause.js';
|
||||
|
||||
export default async function getWargamingResponse<Data extends object>(
|
||||
url: string,
|
||||
@@ -11,8 +12,9 @@ export default async function getWargamingResponse<Data extends object>(
|
||||
if (parsed.status === 'ok') {
|
||||
return parsed.data;
|
||||
} else {
|
||||
throw new Error(
|
||||
`Wargaming response error status:"${parsed.status}" message: "${parsed.error.message}" url: "${url}"`,
|
||||
throw errorWithCause(
|
||||
`Wargaming response error status:"${parsed.status}"`,
|
||||
`Message: "${parsed.error.message}"\nURL: "${url}"`,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user