tRPCttRPC
Powered by
functiondjF
tRPC•13mo ago•
2 replies
functiondj

How can i check if an error is a TRPC Error in the browser?

error.message // NOT_FOUND (throwing this intentionally - i'd like to build a react error boundary that has specific handling for TRPC Errors like NOT_FOUND)
Object.getPrototypeOf(error) // default "Error" object/class
error instanceof TRPCClientError // false. this would have been my best bet.
error.message // NOT_FOUND (throwing this intentionally - i'd like to build a react error boundary that has specific handling for TRPC Errors like NOT_FOUND)
Object.getPrototypeOf(error) // default "Error" object/class
error instanceof TRPCClientError // false. this would have been my best bet.
Solution
Solved: https://trpc.io/docs/client/vanilla/infer-types#infer-trpcclienterror-types
Inferring Types | tRPC
It is often useful to access the types of your API within your clients. For this purpose, you are able to infer the types contained in your AppRouter.
Inferring Types | tRPC
Jump to solution
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

When error in tRPC route, the error message is vauge
cadamsCcadams / ❓-help
3y ago
How can I infer the trpc.procedure.mutationOptions type?
AnonTGAAnonTG / ❓-help
2mo ago
How can I use a fork of trpc-next?
glowyGglowy / ❓-help
4y ago
cant access trpc endpoints via the browser
SonSSon / ❓-help
4y ago