Skip to content

Custom ErrorHandlers are not used by ErrorHandlerMiddleware #11323

@chinpei215

Description

@chinpei215

This is a (multiple allowed):

  • bug

  • enhancement

  • feature-discussion (RFC)

  • CakePHP Version: 3.5.3

  • Platform and Target: PHP7

What you did

Declare the following controller:

class TestsController extends AppController
{
    public function exception() {
        throw new \Exception();
    }

    public function error() {
        throw new \Error();
    }
}

Access /tests/exception and /tests/error.

What happened

While Exceptions are handled by ErrorHandlerMiddleware::handleException(), PHP7 Errors are handled by ErrorHandler::handleException().

What you expected to happen

Both Exceptions and PHP7 Errors are handled by ErrorHandlerMiddleware::handleException() if ErrorHandlerMiddleware is enabled.

Related code

public function __invoke($request, $response, $next)
{
try {
return $next($request, $response);
} catch (Exception $e) {
return $this->handleException($e, $request, $response);
}
}

Related issues

#8997, #9500, #9931

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions