tRPCttRPC
Powered by
TheoT
tRPC•3y ago•
3 replies
Theo

How to use the errorFormatter when using an adapter?

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

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


https://trpc.io/docs/server/error-formatting
Error Formatting | tRPC
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;
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;
Jump to solution
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

errorFormatter ignored when using appRouter.createCaller
seN49SseN49 / ❓-help
3y ago
Guide to create an adapter
Jonatan OrozcoJJonatan Orozco / ❓-help
3y ago
Route not found when using Fastify adapter
TeixeiraTTeixeira / ❓-help
13mo ago