tRPCttRPC
Powered by
seN49S
tRPC•3y ago•
3 replies
seN49

errorFormatter ignored when using appRouter.createCaller

My errorFormatter works correctly in the actual application using an adapter, e.g.
 trpcExpress.createExpressMiddleware({
                router: appRouter,
                createContext: createTRPCContextFromExpress,
            }),
 trpcExpress.createExpressMiddleware({
                router: appRouter,
                createContext: createTRPCContextFromExpress,
            }),


But in my tests where I just use
createCaller
createCaller
, the errorFormatter is never called.

I created a quick sandbox to show this behavior:
https://stackblitz.com/edit/trpc-server-inferred-type-cannot-be-named-x2pseq?file=src/index.ts

When calling
getFoo()
getFoo()
I am expecting the errorFormatter to be called and transform the error to
{ message: 'Huge error' }
{ message: 'Huge error' }
, but when using the
appRouter.createCaller()
appRouter.createCaller()
, the
errorFormatter
errorFormatter
is never called.

Any idea what I am missing?
StackBlitz
@trcp/server v10 Inferred type cannot be named (forked) - StackBlitz
Repro for https://github.com/trpc/trpc/issues/2994
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

How to use the errorFormatter when using an adapter?
TheoTTheo / ❓-help
3y ago
Deprecated createCaller alternative?
HichHHich / ❓-help
13mo ago