I'm trying to understand if there's a way to add global error handling to all my API endpoints.
For eg: Whenever any route throws a MysqlDataTruncation, I know that somebody tried to input invalid data into the database. So, as an alternative to adding redundant checks for each parameter received with the call, I'd like to just use the database internal checks and have a generic "Invalid data input" sent to client.
However, doing the following via StatusPages does not seem to work
When MysqlDataTruncation is thrown, it is caught by neither the first exception declaration inside the StatusPages block, nor by the 'if' check in the second block. Am I doing something wrong or is there another way to do this?
I'm trying to understand if there's a way to add global error handling to all my API endpoints.
For eg: Whenever any route throws a
MysqlDataTruncation
, I know that somebody tried to input invalid data into the database. So, as an alternative to adding redundant checks for each parameter received with the call, I'd like to just use the database internal checks and have a generic "Invalid data input" sent to client.However, doing the following via StatusPages does not seem to work
When
MysqlDataTruncation
is thrown, it is caught by neither the first exception declaration inside the StatusPages block, nor by the 'if' check in the second block. Am I doing something wrong or is there another way to do this?