Skip to content

Recommended way to send custom error codes #809

Answered by KATT
mmkal asked this question in Q&A
Discussion options

You must be logged in to vote

The reason why I currently don't allow custom HTTP codes is that I'm trying to be JSON-RPC compatible in the core as I try it to be independent of the transport layer.

However, I do understand this is might seem a bit too restrictive and I'm open to suggestions on how to make it more flexible.

Here's how the JSON-RPC codes are defined: https://github.com/trpc/trpc/blob/main/packages/server/src/rpc/codes.ts
And here's the HTTP codes for each are mapped: https://github.com/trpc/trpc/blob/main/packages/server/src/http/internals/getHTTPStatusCode.ts

Ideas welcome!

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@KATT
Comment options

@KATT
Comment options

@KATT
Comment options

@mmkal
Comment options

mmkal Aug 20, 2021
Collaborator Author

Answer selected by KATT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants