/** * Handles the given exception * * @param object $exception The exception object - can be \Exception, or some type of \Throwable in PHP 7 * @return void */ public function handleException($exception) { // Ignore if the error is suppressed by using the shut-up operator @ if (error_reporting() === 0) { return; } $this->renderingOptions = $this->resolveCustomRenderingOptions($exception); if (is_object($this->systemLogger) && isset($this->renderingOptions['logException']) && $this->renderingOptions['logException']) { if ($exception instanceof \Throwable) { if ($this->systemLogger instanceof ThrowableLoggerInterface) { $this->systemLogger->logThrowable($exception); } else { // Convert \Throwable to \Exception for non-supporting logger implementations $this->systemLogger->logException(new \Exception($exception->getMessage(), $exception->getCode())); } } elseif ($exception instanceof \Exception) { $this->systemLogger->logException($exception); } } switch (PHP_SAPI) { case 'cli': $this->echoExceptionCli($exception); break; default: $this->echoExceptionWeb($exception); } }