Logging token errors to my logging table

Hi, I've been looking through the forums but haven't found a specific answer to this.

I'm trying to detect when a protected API endpoint encounters a token issue (expired, malformed, or missing).

Currently, if there's a token error, the API immediately returns an error response to the frontend without executing any of the API's function stack.

How can I intercept a token error, identify the error type, and log it to my logging table?

Thanking you

3 replies