how to handle non-trpc errors?
I'm using supabase, and other custom errors within my trpc procedures. The errors thrown are all converted to TRPC errors INTERNAL_SERVER_ERROR, when some of these errors should be converted to other type of TRPC errors. How can i manage this ?
I tried the onError handler, but its too late at this point. the error is already a TRPC error. I tried using a middleware as well, but the errors throw are not caught by the middleware.
The only reference I've found in the docs is here:
https://trpc.io/docs/server/error-handling
but this assumes you are throwing all the errors as TRPC errors from the get go.
Any ideas would be very welcomed!
Error Handling | tRPC
Whenever an error occurs in a procedure, tRPC responds to the client with an object that includes an "error" property. This property contains all the information that you need to handle the error in the client.
1 Reply
You want the next page https://trpc.io/docs/server/error-formatting
Error Formatting | tRPC
The error formatting in your router will be inferred all the way to your client (& React components)