t
tRPC
t
tRPC
Top-level error handling
Original message was deleted
tRPC
Join
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,111
Members
View on Discord
N
Nick
•
3/8/23, 2:23 PM
errorFormatter
, though it works a little differently than you suggest
N
Nick
•
3/13/23, 9:04 AM
I think you need to have a read of the docs page
, you shouldn
't be throwing any new error in there
N
Nick
•
3/13/23, 9:09 AM
Maybe it
's possible but I wouldn
't expect to be able to manipulate the HTTP content in an RPC framework
N
Nick
•
3/13/23, 9:10 AM
You need to let tRPC do its thing and handle errors in javascript via the client
N
Nick
•
3/13/23, 9:10 AM
You can throw a TRPCError in your own code with a relevant error code
N
Nick
•
3/13/23, 9:19 AM
You might be able to use a middleware to catch your own base
-class and re
-emit as a TRPCError
N
Nick
•
3/13/23, 9:20 AM
Do let me know if it works
. I think it should be not 100
% sure
N
Nick
•
3/13/23, 9:20 AM
We
're talking about improved docs right now and I would make sure this goes in
N
Nick
•
3/13/23, 10:44 AM
Makes sense
, middleware order usually matters
N
Nick
•
3/13/23, 10:44 AM
Thanks for that
, looks an essential pattern for us to document
N
Nick
•
3/13/23, 11:52 AM
I always do it but I believe it
’s optional
, you can swap
/extend the context using middlewares