Handling tRPC or React Query errors on the client side.

Hey everyone, I wanted to get prespective on how would you handle errors on the client side side when you're doing a query or mutation. Let's say, it's a login form and the user somehow bypassed the built in input validation in HTML and browsers. How do I handle the error that has been thrown by zod on the server side and do some effect on the client side. Do I catch the error inside
javascript onError(){}
javascript onError(){}
and update some state with the error returned and then make the user know that the input value was wrong. What are other approaches to this?
1 Reply
cje
cje15mo ago
Yes, onError is the place to handle this stuff But you don’t need to worry about the user bypassing validation clientside, at least not in terms of showing nice errors It’s for handling other 400/500 type errors
Want results from more Discord servers?
Add your server