outis99
Explore posts from serversHandling errors on the front-end
I'm making a mutation from my front-end and I intentionally throw a new TRPCError on my backend, I can see the trpc error on both client and server console but I don't understand how to catch it in the front-end
The mutation onError does nothing, myMutation.isError is false, myMutation.error is null and status "idle"
Here's some example code
And then on my code
How I throw the error
I also tried this
Pretty sure I'm just missing something here so a little help would be appreciated, thank you!
16 replies
Can I redirect the user from inside my router?
I have a query protectedProcedure, which returns an object from my prisma planetscale db
What's the best way to redirect the user to a 404 page if the item doesn't exist on the db? I wanted something like
res.redirect("/404")
but can't seem to find a way to do it
Should I just handle it in the front-end with a useEffect?7 replies