mirror of
https://github.com/PretendoNetwork/website.git
synced 2026-10-02 13:36:49 -05:00
feat: add parsable error handling to api methods
This commit is contained in:
10
src/composables/errors.ts
Normal file
10
src/composables/errors.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { FetchError } from 'ofetch';
|
||||
import { getApiError as baseGetApiError } from '~~/shared/errors';
|
||||
import type { ApiError } from '~~/shared/errors';
|
||||
|
||||
export function getApiError(error: any): ApiError {
|
||||
if (error instanceof FetchError) {
|
||||
return baseGetApiError(error.data);
|
||||
}
|
||||
return baseGetApiError(error);
|
||||
}
|
||||
Reference in New Issue
Block a user