Mikey
Mikey
TtRPC
Created by asheeshh on 9/2/2023 in #❓-help
throwing custom errors from mutations
This explains how to get the type from a TRPCClientError
21 replies
TtRPC
Created by asheeshh on 9/2/2023 in #❓-help
throwing custom errors from mutations
Without seeing the rest of your code, it's difficult to help you. But try looking at this: https://trpc.io/docs/client/vanilla/infer-types#infer-trpcclienterror-types
21 replies
TtRPC
Created by asheeshh on 9/2/2023 in #❓-help
throwing custom errors from mutations
Put this before your if statement in the catch block. console.log(e instanceof TRPCClientError) If this is true, then that means you will never run the code in your if statement.
21 replies
TtRPC
Created by asheeshh on 9/2/2023 in #❓-help
throwing custom errors from mutations
This right here...which you said you already did.
21 replies
TtRPC
Created by asheeshh on 9/2/2023 in #❓-help
throwing custom errors from mutations
Can you share your current code and the console.log for it?
21 replies
TtRPC
Created by asheeshh on 9/2/2023 in #❓-help
throwing custom errors from mutations
@asheeshh
21 replies
TtRPC
Created by asheeshh on 9/2/2023 in #❓-help
throwing custom errors from mutations
In the catch, console log out the instanceof for e BEFORE you get into the if statement.
21 replies
TtRPC
Created by asheeshh on 9/2/2023 in #❓-help
throwing custom errors from mutations
@asheeshh try checking the type of your error. You may need to do an if check against TRPC error first and then throw a new error based on what you're experiencing.
21 replies