TheoT
tRPC3y ago
3 replies
Theo

How to use the errorFormatter when using an adapter?

The example here uses context.create(), which isn't something you do when using an adapter.

I don't see an errorFormatter exposed in createExpressMiddleware()

https://trpc.io/docs/server/error-formatting
The error formatting in your router will be inferred all the way to your client (& React components)
Error Formatting | tRPC
Solution
Ah, it was a dumb question. It has nothing to do with adapters.

const t = initTRPC.context<OuterContext>().create({
  errorFormatter({ shape }) {
    
  }
});

export const router = t.router;
export const middleware = t.middleware;
export const mergeRouters = t.mergeRouters;
export const procedure = t.procedure;
Was this page helpful?