protected function getRenderer($exception, $request)
    {
        if (!$this->exceptionRenderer) {
            $this->exceptionRenderer = $this->getConfig('exceptionRenderer') ?: ExceptionRenderer::class;
        }

        // For PHP5 backwards compatibility
        if ($exception instanceof Error) {
            $exception = new PHP7ErrorException($exception);
        }

        if (is_string($this->exceptionRenderer)) {
            $class = App::className($this->exceptionRenderer, 'Error');
            if (!$class) {
                throw new Exception(sprintf(
                    "The '%s' renderer class could not be found.",
                    $this->exceptionRenderer
                ));
            }

            return new $class($exception, $request);
        }
        $factory = $this->exceptionRenderer;

        return $factory($exception, $request);
    }