T
tRPC

Can i use try/catch in procedures?

Can i use try/catch in procedures?

BEbetafuzz ♡ 丑角王子 (e/autism)5/2/2023
can i use try/catch in procedures to pass the error when catching errors in my functions?
Nnlucas5/2/2023
Yes
BEbetafuzz ♡ 丑角王子 (e/autism)5/2/2023
can i pass the error from function to trpc like i need to cast the TRPCError({error})?
try {
....
catch(err) {
throw new TRPCError(err)
}
try {
....
catch(err) {
throw new TRPCError(err)
}
Nnlucas5/2/2023
You don’t need to do the wrapping yourself, tRPC does that automatically. If you need to throw an error just throw it and then you can use an errorFormatter to manipulate what gets sent to the client

Looking for more? Join the community!

T
tRPC

Can i use try/catch in procedures?

Join Server
Recommended Posts
custom query functionI have a use case where I need a trpc procedure call when a specific key is not present in the localTRPC type checking during build failsEnvironment: node 18.6.0, yarn Whats wrong: Type checking at build time fails. . I think this mightcreateTRPCNext config ctx always returns undefined.Hi Everyone. So I'm trying to use TRPC and Nextjs for auth and post query etc. I have client side cStandalone Next.js 13.3.2 errorHi, since the 13.3.2 update of Next.js, I have the following error : ``` TypeError: Cannot read proDoes tRPC works in application network layer (HTTP) or transport network layer (TCP, UDP)?Just wondering if tRPC uses TCP under the hood.returning undefined from server gets stripped on the clientI encounter this issue when working with TRPC React under a Turborepo. But I works fine on Next I sTypeScript, Mono-Repositories and Internal Packages / Project ReferencesI am getting quite frustrate with project references / internal projects and the resolving of types how to integrate with Redis (ioredis)Any middleware?Help to deploy my TRPC proj from a monorepo (turborepo) at VercelI'm trying to learn monorepo with TRPC, both are new for me and Im kind struggling to deploy it becaTRPC ratelimiting endpointsI am currently having some problems with a race condition in my TRPC nextJS api. Essentially what iexpress-session for tRPCI am using express-session for all my servers to create session authentication. Is there something next-prisma-websockets-starter seeds twice on 'pnpm dx'Hi, i'm using this starter template for my app. The `dx` script from package.json runs both `prisma Can you return from an API endpoint before a sync operation is complete?I'm curious, if I have an endpoint that saves something to a DB and I choose to return from the endpuseInfiniteQueryHey i saw on trpc docs that it is used with prisma, but can i so it with drizzle ? How to past curso