best strategy for handling global trpc errors on the client
I’m using trpc in my nextjs app. In one of my procedures, I check if a server is banned. If it is, I throw a
TRPCError
with code FORBIDDEN
and a custom message:
This works, but on the frontend it just results in empty pages being rendered whenever the error is thrown.
I have 20+ pages in my app, and I don’t want to manually add onError logic to every useQuery just to check if the error code is FORBIDDEN
and then render a You are banned
component.
Is there a neater way of handling this error globally?0 Replies