mirror of
https://github.com/enricoros/big-AGI.git
synced 2026-05-10 21:50:14 -07:00
server: improve error formatting, removing unneeded stacks
This commit is contained in:
@@ -48,10 +48,14 @@ const t = initTRPC.context<typeof createTRPCFetchContext>().create({
|
||||
// server transformer - serialize: -> client, deserialize: <- client
|
||||
transformer: transformer,
|
||||
errorFormatter({ shape, error }) {
|
||||
|
||||
// Important: remove the 'stack' from the error data to avoid leaking internals and shorten the payload
|
||||
const { stack, ...nonStackData } = shape.data;
|
||||
|
||||
return {
|
||||
...shape,
|
||||
data: {
|
||||
...shape.data,
|
||||
...nonStackData,
|
||||
zodError:
|
||||
error.cause instanceof z.ZodError ? z.treeifyError(error.cause) : null,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user