error handling
Hi, what is best method to handle errors like incorrect email or password etc, cuz when im using throw new trpcerror i have error info in left down corner
7 Replies
I guess what you're referring to is the little error popup in Next.js.
What I like to do is to wrap my mutation call in a try/catch wrapper function and show a toast in case of errors.
Not sure if this is the best solution but it works.
thx man ❤️

actually this returned the whole bunch of objects whereas i wanna see the message
this is type object trpcclienterror

If you went with this approach and used the
tryTo
function, I think you could check in the catch block if it's a TRPCClientError
and return the message.
Haven't tried it thothat's true, I wonder if there is another way to handle zod validations, i think it can be handled from the front end anyways ?