Skip to content

ErrorHandlerMiddleware does not use App Error configuration as default #14040

@mentisy

Description

@mentisy

This is a (multiple allowed):

  • bug
  • enhancement
  • feature-discussion (RFC)
  • CakePHP Version: 4.0.
  • Platform and Target: apache, mysql, any request that throws an exception

What you did

In config/app.php I have configured a custom errorLogger

'Error' => [
    'errorLevel' => E_ALL,
    'exceptionRenderer' => \Cake\Error\ExceptionRenderer::class,
    'skipLog' => [],
    'log' => true,
    'trace' => true,
    'errorLogger' => \App\Error\ErrorLogger::class,
],

Expected Behavior

I expect that any logging was handled by App\Error\ErrorLogger

Actual Behavior

Every exception is handled by Cake\Error\ErrorLogger.

I think that Cake\Error\Middleware\ErrorHandlerMiddleware should read from configuration if no config is passed to the constructor.

One way to solve it without changing core behavior is to get configuration in ErrorHandlerMiddleware constructor in Application.php, like so:

$middlewareQueue->add(new ErrorHandlerMiddleware(Configure::read('Error')))

My opinion though, for what it's worth, is that it should attempt to use app configuration by default.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions