You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: Distinguish handled and unhandled exceptions #6947
Currently, there is no simple way to distinguish between an intentionally thrown error that you want to send to the client side from an unhandled exception that you don't want to send to the client side and would instead want to pre-process and turn into a generic error message before sending it to the client.
Describe the solution you'd like to see
defaulting unhandled errors to a different UnhandledTrpcError class.
Describe alternate solutions
Creating a different error class manually.
Additional information
No response
👨👧👦 Contributing
🙋♂️ Yes, I'd be down to file a PR implementing this feature!
They're all INTERNAL_SERVER_ERRORs, that's not enough?
@KATT yea so what I want to do is to distinguish between internal server errors that i intentionally and explicitly want to send to the frontend versus those that were thrown by an unexpected error in the code that i didn't handle
so in my trpc error handler i can decide whether to send an error to the front end untouched or whether i should hide the details if it's not something i handled explicitly
That covers it, thanks! Errors declared with .errors() reach the client with their code and data, and everything else gets masked, which is the split I was after, so I'll close this.
This issue has been locked because we are very unlikely to see comments on closed issues. If you are running into a similar issue, please create a new issue. Thank you.
Activity
KATT commentedon Sep 23, 2025
They're all
INTERNAL_SERVER_ERRORs, that's not enough?Feel free to have a stab at it
trpc/packages/server/src/unstable-core-do-not-import/error/TRPCError.ts
Lines 31 to 52 in 1e24e8f
packages/tests/server/errors.test.tsKATT commentedon Sep 23, 2025
you could probably mostly vibe code it
marcospgp commentedon Sep 24, 2025
@KATT yea so what I want to do is to distinguish between internal server errors that i intentionally and explicitly want to send to the frontend versus those that were thrown by an unexpected error in the code that i didn't handle
so in my trpc error handler i can decide whether to send an error to the front end untouched or whether i should hide the details if it's not something i handled explicitly
KATT commentedon Nov 2, 2026
🤖 v12 separates the two: errors a procedure declares with
.errors()reach the client with their code and typeddata, while anything else, a crash included, becomes anINTERNAL_SERVER_ERRORwhose message is masked outside development (or exposed withexposeUnexpectedErrors: true). https://v12.trpc.io/v12/docs/server/errors#on-the-client. v12 isn't released yet and there's no ETA.marcospgp commentedon Nov 23, 2026
That covers it, thanks! Errors declared with
.errors()reach the client with their code and data, and everything else gets masked, which is the split I was after, so I'll close this.github-actions commentedon Nov 25, 2026
This issue has been locked because we are very unlikely to see comments on closed issues. If you are running into a similar issue, please create a new issue. Thank you.