public function handleException($exception, array $error = null) { if (!$exception instanceof \Exception) { $exception = new FatalThrowableError($exception); } $type = $exception instanceof FatalErrorException ? $exception->getSeverity() : E_ERROR; if ($this->loggedErrors & $type) { $e = array('type' => $type, 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'level' => error_reporting(), 'stack' => $exception->getTrace()); if ($exception instanceof FatalErrorException) { if ($exception instanceof FatalThrowableError) { $error = array('type' => $type, 'message' => $message = $exception->getMessage(), 'file' => $e['file'], 'line' => $e['line']); } else { $message = 'Fatal ' . $exception->getMessage(); } } elseif ($exception instanceof \ErrorException) { $message = 'Uncaught ' . $exception->getMessage(); if ($exception instanceof ContextErrorException) { $e['context'] = $exception->getContext(); } } else { $message = 'Uncaught Exception: ' . $exception->getMessage(); } if ($this->loggedErrors & $e['type']) { $this->loggers[$e['type']][0]->log($this->loggers[$e['type']][1], $message, $e); } } if ($exception instanceof FatalErrorException && !$exception instanceof OutOfMemoryException && $error) { foreach ($this->getFatalErrorHandlers() as $handler) { if ($e = $handler->handleError($error, $exception)) { $exception = $e; break; } } } if (empty($this->exceptionHandler)) { throw $exception; } try { call_user_func($this->exceptionHandler, $exception); } catch (\Exception $handlerException) { } catch (\Throwable $handlerException) { } if (isset($handlerException)) { $this->exceptionHandler = null; $this->handleException($handlerException); } }