feat: 优化handleAPIError函数,返回handler执行结果

This commit is contained in:
2025-12-25 14:54:37 +08:00
parent 616b1ad389
commit 8dc2473a1c

View File

@@ -52,7 +52,7 @@ export function normalizeAPIError(error: unknown): never {
throw new APIError((error instanceof Error ? `${error.message}` : '') || '未知错误', 400);
}
export function handleAPIError(error: unknown, handler: (e: APIError) => void): void {
export function handleAPIError<T extends unknown>(error: unknown, handler: (e: APIError) => T): T {
if (error instanceof APIError) {
return handler(error);
}