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