cakephp: Custom ErrorHandlers are not used by ErrorHandlerMiddleware
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
Related issues
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 22 (22 by maintainers)
Thank you for the clarification. I will try to overload
ErrorHandlerMiddleware::__construct(). But if it is difficult, I will give up and createExceptionLoggerinstead.All PHP errors go to the existing ErrorHandler and not the middleware. Using the ErrorHandler inside the middleware presents a couple challenges.
These are solvable issues, but they should be figured out.
Yes. And if there are no problems, I would like to add the same catch blocks to Connection::transactional() too. Otherwise, if people use DatabaseLog engine, the logs are not logged if PHP7 errors happen in transactions.