Render errors

@param \Modulus\Http\Request
@param Exception $exception
@return
177089
public function render($request, Exception $exception)
  {
    $exception = $this->prepare($exception);

    if ($exception instanceof ClientErrorsException) {
      return $exception->handle();
    }

    if ($exception instanceof ServerErrorsException) {
      return $exception->handle();
    }

    Events::trigger('internal.error', [$exception]);
  }
202337
public function render($request, Exception $e)
    {
        $response = $this->exceptionHandler->render($request, $e);

        if ($this->shouldRenderException($response) === true) {
            $_SERVER = $request->server();
            $response->setContent(
                $this->debuggerManager->exceptionHandler($e)
            );
        }

        return $response;
    }
1362974
protected function renderHttpResponse(Exception $e)
    {
        $this->getExceptionHandler()->render($this->app['request'], $e)->send();
    }
1273652
public function render($request, Exception $e)
    {
        if (app()->environment() == 'testing') {
            throw $e;
        }
        if ($e instanceof NotFoundHttpException) {
            if ($request->method() == "GET") {
                return array_key_exists('extension', pathinfo(array_key_exists('path', $parsed = parse_url($request->url()))
                        ? $parsed['path']
                        : null))
                    ? errors(['Not Found'], 404)
                    : html()->generate(); 
            } 
            return errors(['Not Found'], 404);
        }
        if ($e instanceof MethodNotAllowedHttpException) {
            if ($request->method() == "GET") {
                return html()->generate();
            }  
            return parent::render($request, $e);          
        }
        if (app()->environment() == 'local') {
            return errors([$e->getMessage(), $e->getFile() . ': line ' . $e->getLine()], 500);
        }
        return errors([$e->getMessage()], 500);
    }
861243
protected function renderException(Throwable $exception)
    {
        $code = Response::HTTP_INTERNAL_SERVER_ERROR;
        if ($exception instanceof HttpExceptionInterface) {
            $code = $exception->getStatusCode();
        } elseif ($exception instanceof AccessDeniedException || $exception instanceof InvalidCsrfTokenException) {
            $code = Response::HTTP_FORBIDDEN;
        }

        return $this->template->render(sprintf($this->path, $code), [
            'exception' => $exception,
        ]);
    }
649049
public function render($request, Exception $e)
    {
        if ($this->isHttpException($e)) {
            $code = $e->getStatusCode();

            if ($code !== 500 || App::environment('production') || App::environment('staging')) {
                $page = Page::findByInternalName($code);

                if ($page) {
                    $request = Request::create($page->url()->getLocation(), 'GET');

                    return response(Route::dispatch($request)->getContent(), $code);
                }
            }
        }

        return parent::render($request, $e);
    }
612050
public function convertExceptionToHtml($exception)
    {
        $flat = $this->getFlattenedException($exception);

        $handler = new SymfonyExceptionHandler();

        return $this->decorate($handler->getContent($flat), $handler->getStylesheet($flat), $flat);
    }
923807
protected function renderHtmlErrorMessage(HttpException $exception)
    {
        $title = $exception->getName();
        $html = '<p>' . $exception->getMessage() . '</p>';

        $output = sprintf(
            "<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" .
            "<title>%s</title><style>body{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana," .
            "sans-serif;}h1{margin:0;font-size:48px;font-weight:normal;line-height:48px;}strong{" .
            "display:inline-block;width:65px;}</style></head><body><h1>%s</h1>%s</body></html>",
            $title,
            $title,
            $html
        );

        return $output;
    }
47253
public function display(Exception $exception)
	{
		$status = $exception instanceof HttpExceptionInterface ? $exception->getStatusCode() : 500;

		return new Response($this->whoops->handleException($exception), $status);
	}
860763
protected function _displayException($exception)
    {
        $rendererClassName = App::className($this->_options['exceptionRenderer'], 'Error');
        try {
            if (!$rendererClassName) {
                throw new Exception("$rendererClassName is an invalid class.");
            }
            /** @var \Cake\Error\ExceptionRendererInterface $renderer */
            $renderer = new $rendererClassName($exception);
            $response = $renderer->render();
            $this->_clearOutput();
            $this->_sendResponse($response);
        } catch (Throwable $exception) {
            $this->_logInternalError($exception);
        } catch (Exception $exception) {
            $this->_logInternalError($exception);
        }
    }
1135885
protected function renderException($exception)
    {
        $contentType = static::getContentType();
        $dataType = explode('/', $contentType);
        $dataType = isset($dataType[1]) ? $dataType[1] : 'text';

        switch ($dataType) {
            case 'json':
                $output = $this->getJsonMessage($exception);
                break;
                
            case 'xml':
                $output = $this->getXmlMessage($exception);
                break;
            
            case 'html':
                $output = $this->getHtmlMessage($exception);
                break;
                
            case 'text':
            default:
                $output = $this->getTextMessage($exception);
        }
        
        echo $output;
    }
113887
protected function handleException($request, Exception $e)
    {
        $this->reportException($e);

        return $this->renderException($request, $e);
    }
949703
public function render($request, Exception $e)
    {
        if ($e instanceof HttpResponseException) {
            return $e->getResponse();
        }

        if ($this->isHttpException($e)) {
            return $this->toIlluminateResponse($this->renderHttpException($e), $e);
        } else {
            return $this->toIlluminateResponse($this->convertExceptionToResponse($e), $e);
        }
    }
1003249
protected function renderHttpException(HttpException $e)
    {
        $status = $e->getStatusCode();

        if (view()->exists($this->getViewPath("errors.{$status}"))) {
            return response()->view($this->getViewPath("errors.{$status}"), ['exception' => $e], $status, $e->getHeaders());
        } elseif (view()->exists($this->getViewPath('errors.other'))) {
            return response()->view($this->getViewPath('errors.other'), ['exception' => $e], $status, $e->getHeaders());
        }

        return $this->convertExceptionToResponse($e);
    }
385355
protected function throwError($exception)
    {
        switch ($exception->getResponse()->getStatusCode()) {
            case 400:
                throw new BadRequestException($exception);
                break;

            case 401:
                throw new UnauthorizedException($exception);
                break;

            case 403:
                throw new MethodNotAllowedException($exception);
                break;

            case 404:
                throw new NotFoundException($exception);
                break;

            default:
                throw new Exception($exception);
                break;
        }
    }
657187
public function render(Request $request, Exception $e)
    {
        $e = $this->prepareException($e);

        if ($e instanceof HttpResponseException) {
            return $e->getResponse();
        } else if ($e instanceof AuthenticationException) {
            return $this->unauthenticated($request, $e);
        } else if ($e instanceof ValidationException) {
            return $this->convertValidationExceptionToResponse($e, $request);
        }

        return $this->prepareResponse($request, $e);
    }
16894
public function render(Exception $e)
    {
        if ($e instanceof HttpResponseException) {
            /* error occurs */
            switch ($e->getCode()) {
                case HttpResponseException::ERR_NOTFOUND_CONTROLLER:
                case HttpResponseException::ERR_NOTFOUND_ACTION:
                case HttpResponseException::ERR_NOTFOUND_VIEW:
                    response()->setStatusCode(404);
                    echo htmlspecialchars($e->getMessage());
                    break;
                default :
                    echo 0, ':', htmlspecialchars($e->getMessage());
                    break;
            }
        } else {
            $this->convertExceptionToResponse($e);
        }
    }