Handle specific tRPC errors centrally
I would like to handle some errors of all of my queries centrally.
e.g. I would like to have an 401 error always be handled the same way -> reroute the user to my login page. So I would like to prevent adding an onError func to every query I'm doing in my client.
Is there a way to do that?
I looked for a place to do it and found
Problem here is this isn't client side, so I can't call hooks including my router.
e.g. I would like to have an 401 error always be handled the same way -> reroute the user to my login page. So I would like to prevent adding an onError func to every query I'm doing in my client.
Is there a way to do that?
I looked for a place to do it and found
/server/trpc/trpc.ts where it sets up the protectedProcedure with the isAuthed function.Problem here is this isn't client side, so I can't call hooks including my router.
