public function test_convert_error_to_exception_and_call_handler_and_handle_exception() { $converter = new ErrorConverter(); $handler = new ErrorHandler(true); $handler->addExceptionHandler(function (ErrorException $ex) { return true; }); $error = new RecoverableError(ErrorType::ERROR, 'foo', 'bar', 'yolo'); $converter->convertErrorToExceptionAndCallHandler($handler, $error); }
/** * @param IError $error * * @return bool|void */ public function handleFatalError(IError $error) { // ignore error caused by a rethrown exception if ($this->ignoreRethrownException) { $this->ignoreRethrownException = false; return; } $ob = ob_get_clean(); if ($this->isConvertingErrorsToExceptions()) { return $this->errorConverter->convertErrorToExceptionAndCallHandler($this, $error); } foreach ($this->getFatalErrorHandlers() as $handler) { if ($handler->isEnabled()) { try { $handled = $handler->handle($error); if ($handled === true) { return; } } catch (Exception $ex) { $handler->setEnabled(false); $this->handleException($ex); } } } echo $ob; }