Luca
Luca14mo ago

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

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?
2 Replies