T
tRPC

throwing custom errors from mutations

throwing custom errors from mutations

Aasheeshh9/2/2023
any idea why trpc is ignoring the catch expression? it just throws its own error about unique constraint violation
No description
MMikey9/2/2023
@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.
Aasheeshh9/2/2023
youre asking me to check the error type on the client side?
MMikey9/2/2023
In the catch, console log out the instanceof for e BEFORE you get into the if statement. @asheeshh
Aasheeshh9/2/2023
oh actually the thing is my catch expression is completely ignored by trpc nothing inside catch runs already tried console logging stuff inside it
MMikey9/2/2023
Can you share your current code and the console.log for it?
Aasheeshh9/2/2023
console log? of what?
MMikey9/2/2023
This right here...which you said you already did.
Aasheeshh9/2/2023
this is the error thrown by trpc
No description
Aasheeshh9/2/2023
i just added a console log inside catch to print the error
MMikey9/2/2023
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.
Aasheeshh9/2/2023
nothing inside or outside of the if statements is running the whole catch expression doesnt run when an error is thrown
MMikey9/2/2023
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 This explains how to get the type from a TRPCClientError
DDani;9/3/2023
Pretty sure you need to await the promise inside the try-catch block

Looking for more? Join the community!

T
tRPC

throwing custom errors from mutations

Join Server
Recommended Posts
trpc in a pnpm monorepoHi all 👋 I was wondering if there is a recommended setup for monorepos, in our case with pnpm workTS Error with React when creating client "useContext" collides ....when creating the client i get following error: The property 'useContext' in your router collides wType 'NextRequest' is missing properties from type 'NextApiRequest'Enviorment: Node 18, pnpm Hi, I'm facing an error, where in my app i get this error at `createTRPCCType '{}' is not assignable in server queryType '{ input: { slug: string; }; "": any; }' is not assignable to type 'string | StringFilter<"CateThe inferred type of this node exceeds the maximum length the compiler will serialize.Using HTTP:POST for `query`?Hey guys, thanks for the awesome library! My application involves making a `query` with a large amre validation on static site next js 13Hi, does any one know how to make revaluation when I’m fetching data on the server client from DB wiTransformers not transforming data (trpc-sveltekit)I'm having some trouble getting superjson to do its magic with tRPC & SvelteKit. I have a `client.tsIssue Inferring Type on Frontend with ElectroDB Query Return StatementHi all, I am using ElectroDB to work with DynamoDB, and I have a Lambda function that uses tRPC thaWrong JSON response when deployedWhen testing in localhost in dev mode there is no issue and the response is correct as expected. BuExternal callsHi! I am using T3 stack, tRPC together with clerk, and i need to create users within the app, being Need help identifying the generic client side type of proceduresHi! I think my question is better explained by what I'm trying to achive than anything else: I likIs there a way to use versioning for procedures?I want to make multiple versions (v1 / v2) for a procedure, can i do it in procedure level?createSSGHelpersI'm trying to fetch data in getStaticProps and getting the issue "Promise<{ paths: { params: { id: nTRPC undefined when exportingHi i am working on merging routers from different files but when exporting the router property it coTRPC retries with new app dir```ts let { data: name, isLoading, isFetching, isError, error } = trpc.home.home.useQuery(); ```opts.input is of type undifined```ts register: publicProcedure.input( RegisterSchema ).mutation(async (opts) => { Server-side error tracing with DatadogHey, has anyone had any luck setting up tracing with tRPC? Specifically with `dd-trace-js`. We’re uConfiguration helpHello! I want to apply the following configuration on the client: https://tanstack.com/query/v4/docI'm curious to know if anyone has any suggestions on how I can track the replies to the emailsI'm curious to know if anyone has any suggestions on how I can track the replies to the emails I sen