Custom Error Rendering

Hello Everyone

I am developing an application where I need the errors to be presented in a certain way.

In CakePHP 4, I was able to do this simply by implementing a Custom ExceptionRenderer.

Problem

However, in CakePHP 5 I am encountering an error that I can’t seem to resolve:

Uncaught Cake\Error\FatalErrorException: [InvalidArgumentException] Cannot use `App\Error\CustomErrorRenderer` as an `exceptionRenderer`. It must be an instance of `Cake\Error\ExceptionRendererInterface`

Even when using the example provided in the CakePHP 5 documentation, I still can't solve it.

Reference
Here is the page I am referring to:

CakePHP 5 Documentation on Custom ExceptionRenderer

Thank you very much for your time.

are you sure your custom class implements Cake\Error\ExceptionRendererInterface?

See e.g. https://github.com/dereuromark/cakephp-whoops/blob/master/src/Error/WhoopsExceptionRenderer.php which also works fine for cake5