T
tRPC

Error handling: Zod errors and manually thrown TRPCErrors have different shape

Error handling: Zod errors and manually thrown TRPCErrors have different shape

LLuca6/14/2023
If zod validation fails, the client-side error.message contains a JSON encoded array of errors, but if a TRPCError is thrown in a procedure, error.message is simply the error message. Why do they have a different shape? How should I go about this? Should I try to standardize both to a JSON encoded array on the server? Or should I try to distinguish the two scenarios on the client-side?

Looking for more? Join the community!

T
tRPC

Error handling: Zod errors and manually thrown TRPCErrors have different shape

Join Server