Skip to content
Discussion options

You must be logged in to vote

Yes, ORPC supports middleware and lifecycle hooks that let you centrally intercept and normalize errors before they reach the client. You can use the .use() method to add middleware to your handlers, and inside the middleware, catch errors thrown by downstream handlers or other middleware, then transform or normalize them as needed—such as converting unexpected errors into a consistent ORPC error object or mapping custom errors to your preferred format. This pattern is documented and widely used for centralized error handling in ORPC (docs, middleware docs, discussion).

For example:

const errorNormalizer = os.middleware(async ({ next, errors }) => {
  try {
    return await next();
  } c…

Replies: 1 comment 4 replies

Comment options

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

@dosubot
Comment options

Answer selected by girishcx07
@unnoq
Comment options

@girishcx07
Comment options

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