The question is a continuation of the problem described here .
I am writing an error handler class in PHP7. Install error handlers:
set_error_handler([$this, 'errorHandler']); set_exception_handler([$this, 'exceptionHandler']); ob_start(); register_shutdown_function([$this, 'fatalErrorHandler']); The handlers themselves:
public function fatalErrorHandler() { ob_clean(); $error = error_get_last(); if ( !empty($error) && $this->isFatalError($error['type']) ) { throw new ErrorException($error['message'], $error['type']); } throw new ErrorException('Error'); } and
public function exceptionHandler(\Throwable $e) { $this->error = [ 'code' => $e->getCode(), 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine() ]; $this->displayError(); $this->log(); } The ErrorException class is a descendant of Exception β the descendant of the base \ Exception. There added a couple of methods.
It turns out, PHP just complains about the string included in the constructor by the first argument. Similarly, if you throw the base \ Exception. What is the problem?
