seN49
seN49β€’2y ago

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, 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?
2 Replies
Nick
Nickβ€’2y ago
Could you open a GitHub issue for this? It might be intentional but I agree it’s illogical as a user Since you have a reproduction case already we can investigate πŸ™‚
seN49
seN49OPβ€’2y ago
GitHub
bug: errorFormatter ignored when using appRouter.createCaller Β· Iss...
Provide environment information System: OS: macOS 13.2.1 CPU: (10) arm64 Apple M1 Pro Memory: 3.36 GB / 32.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/...