feat: 前端添加GeneralErrorHandler
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import { toast } from "sonner";
|
||||||
|
|
||||||
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
||||||
|
|
||||||
export interface APIResponse<T = unknown> {
|
export interface APIResponse<T = unknown> {
|
||||||
@@ -64,4 +66,8 @@ export function handleAPIError(error: unknown, handler: (e: APIError) => void):
|
|||||||
|
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function GeneralErrorHandler(e: APIError) {
|
||||||
|
toast.error(`${e.message}`)
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user