Skip to content
Discussion options

You must be logged in to vote

I guess I should have been more clear in my original question. We're only using the OpenAPIHandler. I randomly discovered the customErrorResponseBodyEncoder and errorStatusMap options for the OpenAPIHandler constructor, which allows me to preserve our error structure without needing any client changes. Here is what I'm doing.

  1. Throw custom errors.
  2. Add middleware to wrap custom errors in ORPCError with the custom error in cause and any supporting information (like validation errors) in data. Throw the ORPCError.
  3. Include a customErrorResponseBodyEncoder function to unwrap the ORPCError and return the desired error format.

I'm also utilizing the errorStatusMap option to map our custom error…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@brannonh
Comment options

Comment options

You must be logged in to vote
2 replies
@dinwwwh
Comment options

@brannonh
Comment options

Answer selected by brannonh
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