src/Web/ErrorHandler.php
protected function renderException($exception)
    {
        $response = $this->app->response;

        $response->setStatusCodeByException($exception);

        $useErrorView = $response->format === Response::FORMAT_HTML && (!Reaction::isDebug() || $exception instanceof UserException);

        if ($useErrorView && $this->errorAction !== null) {
            $result = $this->app->resolveAction($this->errorAction, 'GET');
            if ($result instanceof Response) {
                return $result;
            } elseif ($result instanceof ResponseBuilderInterface) {
                $response = $result;
            } else {
                $response->setBody($result);
            }
        } elseif ($response->format === Response::FORMAT_HTML) {
            if ($this->shouldRenderSimpleHtml()) {
                // AJAX request
                $response->setBody('<pre>' . $this->htmlEncode(static::convertExceptionToString($exception)) . '</pre>');
            } else {
                // if there is an error during error rendering it's useful to
                // display PHP error in debug mode instead of a blank screen
                if (Reaction::isDebug()) {
                    ini_set('display_errors', 1);
                }
                $file = $useErrorView ? $this->errorView : $this->exceptionView;
                $response->setBody($this->renderFile($file, [
                    'exception' => $exception,
                ]));
            }
        } elseif ($response->format === Response::FORMAT_RAW) {
            $response->setBody(static::convertExceptionToString($exception));
        } else {
            $response->setBody($this->convertExceptionToArray($exception));
        }

        return $response->build();
    }
protected function renderException($exception)
    {
        $response = $this->app->response;

        $response->setStatusCodeByException($exception);

        $useErrorView = $response->format === Response::FORMAT_HTML && (!Reaction::isDebug() || $exception instanceof UserException);

        if ($useErrorView && $this->errorAction !== null) {
            $result = $this->app->resolveAction($this->errorAction, 'GET');
            if ($result instanceof Response) {
                return $result;
            } elseif ($result instanceof ResponseBuilderInterface) {
                $response = $result;
            } else {
                $response->setBody($result);
            }
        } elseif ($response->format === Response::FORMAT_HTML) {
            if ($this->shouldRenderSimpleHtml()) {
                // AJAX request
                $response->setBody('<pre>' . $this->htmlEncode(static::convertExceptionToString($exception)) . '</pre>');
            } else {
                // if there is an error during error rendering it's useful to
                // display PHP error in debug mode instead of a blank screen
                if (Reaction::isDebug()) {
                    ini_set('display_errors', 1);
                }
                $file = $useErrorView ? $this->errorView : $this->exceptionView;
                $response->setBody($this->renderFile($file, [
                    'exception' => $exception,
                ]));
            }
        } elseif ($response->format === Response::FORMAT_RAW) {
            $response->setBody(static::convertExceptionToString($exception));
        } else {
            $response->setBody($this->convertExceptionToArray($exception));
        }

        return $response->build();
    }
Renders the exception.
@param \Exception|\Error $exception the exception to be rendered.
@return Response