TRPCError that has TRPCError as cause

Having some troubles with error handling, specifically, my errors are double-wrapped in a TRPCError. What I'm doing is basically having a mutation that does:
something: t.procedure
.input(mySchema)
.mutation() => Promise.reject(new Error('oh no'))),
something: t.procedure
.input(mySchema)
.mutation() => Promise.reject(new Error('oh no'))),
and then, the onError handler has:
onError({ error }) {
console.log('onError', error.name, error.cause.name)
},
onError({ error }) {
console.log('onError', error.name, error.cause.name)
},
which logs: onError TRPCError TRPCError. If I then go further with error.cause.cause.name, I can see my error. I already tried to reproduce this in isolation, but in a sandbox, I get: onError TRPCError Error, which is what I would expect. Just wanted to know if anyone has seen something similar; Not sure how this can happen ... thanks
Alex / KATT ๐Ÿฑ
Alex / KATT ๐Ÿฑโ€ข235d ago
hmmmm this is weird
Alex / KATT ๐Ÿฑ
Alex / KATT ๐Ÿฑโ€ข235d ago
GitHub
Setting TRPCError.name to "TRPCError" by dios-david ยท Pull Request ...
๐ŸŽฏ Changes Setting this.name to "TRPCError" in the TRPCError constructor instead of using this.constructor.name. Background I ran into an issue with my trpc server where the production bui...
Alex / KATT ๐Ÿฑ
Alex / KATT ๐Ÿฑโ€ข235d ago
i'll try to push that try upgrading to 10.38.5
TkDodo ๐Ÿ”ฎ
TkDodo ๐Ÿ”ฎโ€ข231d ago
yeah that fixes it. Thank you so much ๐Ÿ™ I'm not quite sure why I couldn't reproduce it in isolation though
More Posts
How do you make use of custom input validation?I have an input validation middleware, to parse my input based on some values in ctx. ``` export fuWhy useQuery() tries to refetch when error occurs while useMutation() doesn't?I'm using the T3 stack. ```test: publicProcedure.input(z.string().min(5)).query(async () => { Lambda WITHOUT API Gateway (Lambda Function URL)Anyone know how to make this work?In a monorepo can I have 2 packages each one with different trpc server, and use both in 1 app?I want to create 2 different APIs, and in my monorepo I have several apps, in some I want to use botHave you used electron-trpc? how does it work for you? Do you recommend it?https://www.electron-trpc.dev/ Thankstrpc error fetch failedplease helpHow to type a helper function to standardise loading and error states with a useQuery call?I am trying to standardize handling of error and loading states. I'd like to have one function/compoTypeScript Issue: router.createCaller Implicitly has Return Type "any"Hello everyone, I'm currently working on a project using tRPC and Prisma. However, I've run into an2 react renders causing 4 trpc query executesI see that my nextjs page is rendering twice on initial load. This is causing 4 executes of my querySuspend subscriptions when app is in backgroundWhen using React Native, subscriptions stay open even when the app is in the background. While this Callbacks in Consecutive MutationsI seem to be running into this issue https://tanstack.com/query/v4/docs/react/guides/mutations#consereturn type of a query endpointHello I currently have a trpc endpoint: ```ts const customInstances = api.customInstance.userCust