Theo's Typesafe CultTTC
Theo's Typesafe Cult3y ago
3 replies
H

tRPC Error handling

im trying to understand how tRPC handle 400 errors request
what i got so far is im doing this in my procedure
      if (exam) throw new TRPCError({ code: "BAD_REQUEST" }); 

and in client im getting an error like so
but i want to handle the error in client as i want without getting the nextjs error ui
i just want a response with message and 400 status
the equivalent of if (exam) res.status(400).json({message:"you have an error"}) in express
chrome_fenk3FOjq9.png
Was this page helpful?