mirror of
https://github.com/enricoros/big-AGI.git
synced 2026-05-10 21:50:14 -07:00
Wire/server: pretty-print server-side Zod errors in return messages #851
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import * as z from 'zod/v4';
|
||||
|
||||
/// set this to true to see the tRPC and fetch requests made by the server
|
||||
export const SERVER_DEBUG_WIRE = false; //
|
||||
|
||||
@@ -56,6 +58,10 @@ export function safeErrorString(error: any): string | null {
|
||||
return `AggregateError: ${errors.join('; ')}`;
|
||||
}
|
||||
|
||||
// handle zod v4 errors
|
||||
if (error instanceof z.ZodError)
|
||||
return z.prettifyError(error);
|
||||
|
||||
// descend into an 'error' object
|
||||
if (error.error)
|
||||
return safeErrorString(error.error);
|
||||
|
||||
Reference in New Issue
Block a user