rdR
tRPC3y ago
3 replies
rd

Throwing fastify errors when using fastify adapter

Hello, I'm using
fastifyTRPCPlugin
from
@trpc/server/adapters/fastify
and trying to throw errors correctly.

I usually use
@fastify-sensible
because I find the API clear, e.g. I can write things like
fastify.httpErrors.forbidden()
or
fastify.httpErrors.unauthorized
.

However if I throw one of these in a tRPC procedure it seems the error code is always 500, assuming that's because tRPC is intercepting/handling them in some way? What's the best way to "solve" this? Thanks!
Was this page helpful?