seN49S
tRPC3y 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,
            }),


But in my tests where I just use
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()
I am expecting the errorFormatter to be called and transform the error to
{ message: 'Huge error' }
, but when using the
appRouter.createCaller()
, the
errorFormatter
is never called.

Any idea what I am missing?
Was this page helpful?