aryzing
aryzing7mo ago

What's the negative code returned in error responses?

What's the negative error code returned in errors responses and how is it meant to be used by the client?
Solution:
tRPC is compliant with JSON-RPC and has specific error codes. You can find them here; The docs have a great explanation on handling errors....
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.
GitHub
trpc/packages/server/src/rpc/codes.ts at 43e0da13073c8e5426c4c4fb6c...
🧙‍♀️ Move Fast and Break Nothing. End-to-end typesafe APIs made easy. - trpc/trpc
Jump to solution
3 Replies
Solution
Tamás Soós
Tamás Soós7mo ago
tRPC is compliant with JSON-RPC and has specific error codes. You can find them here; The docs have a great explanation on handling errors.
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.
GitHub
trpc/packages/server/src/rpc/codes.ts at 43e0da13073c8e5426c4c4fb6c...
🧙‍♀️ Move Fast and Break Nothing. End-to-end typesafe APIs made easy. - trpc/trpc
aryzing
aryzing7mo ago
The error handling docs are great, and would be better if they contained an explanation of (or link to) what code is. Towards the end of the docs, there's a collapsed section at the end of this page explaining the codes, https://trpc.io/docs/rpc#error-codes---json-rpc-20-error-codes
Alex / KATT 🐱
feel free to make a PR! 🙂