T
Join ServertRPC
❓-help
Can i use try/catch in procedures?
can i use try/catch in procedures to pass the error when catching errors in my functions?
Yes
can i pass the error from function to trpc
like i need to cast the TRPCError({error})?
try {
....
catch(err) {
throw new TRPCError(err)
}
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