Hi, I'm involved in a next/trpc application, and have hit a bit of a wall while trying to deal with intercepting specific errors (globally across the application, as it comes from an auth middleware) to perform some steps if that error occurs (specifically logging the user out). At this point I've set things up so I'm able to pass through additional metadata (an error id in particular) with the error, to identify it, however I'm having difficulty finding a point at which the error can be properly intercepted. We have a global-error.tsx file, which picks up the error, however it does so with stripped down data, meaning the only identifier we could use (as far as I can tell) is the message. However I'd like to avoid using the message as such, as it could feasibly change in the future.
Is there a streamlined means through which the frontend can handle api errors for this purpose that I'm missing?