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
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 express3 Replies
In your
useQuery
you can extract the error
variable and inspect it to see what it contains. Then you can render what you need.
Although it depends, if you are using suspense you will need to catch the error with an error boundary insteadyea that what i did i handled the error in a try catch
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View