tRPCttRPC
Powered by
TkDodo ๐Ÿ”ฎT
tRPCโ€ข4y agoโ€ข
17 replies
TkDodo ๐Ÿ”ฎ

Error handling

We have some trpc routers that make requests to another api - we use axios for that. I'd like to forward these errors to the frontend, so if that api errors with 401, that's what I'd like to see in the browser.
If I just await the request and don't catch the errors, I get a 500 error where the message is the message from the axios request.
What would be the best way to handle this, globally? I wouldn't really want to wrap each api in a try / catch, and I'd also ideally not need to translate those errors to TRPCErrors...
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

error handling
SzymonSSzymon / โ“-help
13mo ago
TRPC Error Handling
RudejellyfishRRudejellyfish / โ“-help
3y ago
Handling error globally
MugetsuMMugetsu / โ“-help
4y ago