ErrorHandlerMiddleware.php 716 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace Tools\Error\Middleware;
  3. use Cake\Core\Configure;
  4. use Cake\Error\Middleware\ErrorHandlerMiddleware as CoreErrorHandlerMiddleware;
  5. use Tools\Error\ErrorHandler;
  6. /**
  7. * Custom ErrorHandler to not mix the 404 exceptions with the rest of "real" errors in the error.log file.
  8. */
  9. class ErrorHandlerMiddleware extends CoreErrorHandlerMiddleware {
  10. /**
  11. * @param \Cake\Error\ErrorHandler|array $errorHandler The error handler instance
  12. * or config array.
  13. */
  14. public function __construct($errorHandler = []) {
  15. if (is_array($errorHandler)) {
  16. $errorHandler += Configure::read('Error');
  17. }
  18. parent::__construct($errorHandler);
  19. $this->errorHandler = new ErrorHandler($this->getConfig());
  20. }
  21. }