Create custom error handler

Hello,

By following https://www.slimframework.com/docs/handlers/error.html this link, I am able to override the existing error handlers in Slim.
In \Slim\App::handleException() I see there are 3 which are registered. In my project I want to introduce 2 new error handlers like:

  • badRequestHandler - to show 400 Bad Request and to log each bad request to logger.

  • tooManyRequestHandler - to show 429 Too Many Request as a result of rate limitations.

Is there a way to do this? Do I have to override ‘protected function handleException’ for this?

Regards,
Aneek