feat: 前端添加GeneralErrorHandler

This commit is contained in:
2025-12-18 21:45:37 +08:00
parent bc1fdc5b57
commit 7f93a17526

View File

@@ -1,3 +1,5 @@
import { toast } from "sonner";
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
export interface APIResponse<T = unknown> {
@@ -64,4 +66,8 @@ export function handleAPIError(error: unknown, handler: (e: APIError) => void):
throw error;
}
}
export function GeneralErrorHandler(e: APIError) {
toast.error(`${e.message}`)
}