Render html

@param ServerErrorsException $exception
@return void
351233
private function toHtml(ServerErrorsException $exception)
  {
    View::make('app.errors.default', [
      'title'      => $exception->getTitle(),
      'message'    => $exception->getMessage(),
      'statusCode' => $exception->getStatusCode()
    ]);
  }
369368
private function handleError(ServerRequestInterface $request, HttpErrorException $exception): ResponseInterface
    {
        $request = $request->withAttribute($this->attribute, $exception);
        $handler = $this->handler ?: new ErrorHandlerDefault();

        return $handler->handle($request);
    }
1189793
public function handleException(ServerRequestInterface $request, ResponseInterface $response, Exception $exception)
    {
        return $this->withError($response, $exception);
    }
733154
protected function _displayException($exception)
    {
        $errorName = 'Exception:';
        if ($exception instanceof FatalErrorException) {
            $errorName = 'Fatal Error:';
        }

        if ($exception instanceof PHP7ErrorException) {
            $exception = $exception->getError();
        }

        $message = sprintf(
            '<error>%s</error> %s in [%s, line %s]',
            $errorName,
            $exception->getMessage(),
            $exception->getFile(),
            $exception->getLine()
        );
        $this->_stderr->write($message);
    }
1303023
public function renderException($exception)
	{
		if (!$this->getOption('v', 0))
		{
			$this->out('')->out($exception->getMessage());

			return;
		}

		parent::renderException($exception);
	}
452629
public function html(WebException $exception) {
    $message = $exception->getMessage();
    $statusCode = $exception->getStatusCode();
    $details = $exception->getDetails() === null ? "" : $exception->getDetails();
    return "
      <!DOCTYPE html>
      <html>
        <head><title>$message</title></head>
        <body>
          <h1>HTTP $statusCode: $message</h1>
          <p>$details</p>
        </body>
      </html>
    ";
  }
1027821
protected function handle(ClientErrorsException $exception)
  {
    if (
      $exception->getStatusCode() == 403 &&
      method_exists($this, 'renderAccessDenied')
    ) {
      return $this->renderAccessDenied($exception);
    } else if (
      $exception->getStatusCode() == 404 &&
      method_exists($this, 'renderNotFound')
    ) {
      return $this->renderNotFound($exception);
    } else if (
      $exception->getStatusCode() == 405 &&
      method_exists($this, 'renderNotAllowed')
    ) {
      return $this->renderAccessDenied($exception);
    } else if (
      $exception->getStatusCode() == 429 &&
      method_exists($this, 'renderTooManyRequests')
    ) {
      return $this->renderTooManyRequests($exception);
    }

    if ($exception->isAjax()) {
      $this->toJson($exception);
      return;
    }

    $this->toHtml($exception);
  }
274000
public function render($request, Exception $exception)
    {
        if ($exception instanceof TokenExpiredException) {
            return response()->json(['token_expired'], $exception->getCode());
        } else if ($exception instanceof TokenInvalidException) {
            return response()->json(['token_invalid'], $exception->getCode());
        }
        return parent::render($request, $exception);
    }
409099
public function renderOnException(WrappedExceptionInfo $exceptionInfo, SilexKernel $silexKernel)
    {
        $twig = $silexKernel->getTwig();
        if (!$twig) {
            $response = $this->renderOnSuccess($exceptionInfo->jsonSerialize(), $silexKernel);
        }
        else {
            try {
                $templateName = sprintf("%d.twig", $exceptionInfo->getCode());
                
                $response = new Response(
                    $twig->render($templateName, $exceptionInfo->toArray($silexKernel['debug']))
                );
            } catch (\Twig_Error_Loader $e) {
                $response = $this->renderOnSuccess($exceptionInfo->jsonSerialize(), $silexKernel);
            }
        }
        
        return $response;
    }
53351
public static function renderException(\Exception $exception)
    {
        $error = new MessageBag([
            'type'    => get_class($exception),
            'message' => $exception->getMessage(),
            'file'    => $exception->getFile(),
            'line'    => $exception->getLine(),
            'trace'   => $exception->getTraceAsString(),
        ]);

        $errors = new ViewErrorBag();
        $errors->put('exception', $error);

        return view('admin::partials.exception', compact('errors'))->render();
    }
672729
public function RenderException($Ex) {
      if ($this->DeliveryMethod() == DELIVERY_METHOD_XHTML) {
         try {
            if (is_a($Ex, 'Gdn_UserException')) {
               Gdn::Dispatcher()
                  ->PassData('Code', $Ex->getCode())
                  ->PassData('Exception', $Ex->getMessage())
                  ->PassData('Message', $Ex->getMessage())
                  ->PassData('Trace', $Ex->getTraceAsString())
                  ->PassData('Url', Url())
                  ->PassData('Breadcrumbs', $this->Data('Breadcrumbs', array()))
                  ->Dispatch('/home/error');
            } else {
               switch ($Ex->getCode()) {
                  case 401:
                     Gdn::Dispatcher()
                        ->PassData('Message', $Ex->getMessage())
                        ->PassData('Url', Url())
                        ->Dispatch('DefaultPermission');
                     break;
                  case 404:
                     Gdn::Dispatcher()
                        ->PassData('Message', $Ex->getMessage())
                        ->PassData('Url', Url())
                        ->Dispatch('Default404');
                     break;
                 default:
                    Gdn_ExceptionHandler($Ex);
               }
            }
            
            
         } catch(Exception $Ex2) {
            Gdn_ExceptionHandler($Ex);
         }
         return;
      }

      // Make sure the database connection is closed before exiting.
      $this->Finalize();
      $this->SendHeaders();

      $Code = $Ex->getCode();
      $Data = array('Code' => $Code, 'Exception' => $Ex->getMessage(), 'Class' => get_class($Ex));
      
      if (Debug()) {
         if ($Trace = Trace()) {
            $Data['Trace'] = $Trace;
         }
         
         if (!is_a($Ex, 'Gdn_UserException'))
            $Data['StackTrace'] = $Ex->getTraceAsString();
         
         $Data['Data'] = $this->Data;
      }
      
      // Try cleaning out any notices or errors.
      @@ob_clean();
      

      if ($Code >= 400 && $Code <= 505)
         header("HTTP/1.0 $Code", TRUE, $Code);
      else
         header('HTTP/1.0 500', TRUE, 500);

      
      switch ($this->DeliveryMethod()) {
         case DELIVERY_METHOD_JSON:
            if (($Callback = $this->Request->GetValueFrom(Gdn_Request::INPUT_GET, 'callback', FALSE)) && $this->AllowJSONP()) {
               header('Content-Type: application/javascript', TRUE);
               // This is a jsonp request.
               exit($Callback.'('.json_encode($Data).');');
            } else {
               header('Content-Type: application/json', TRUE);
               // This is a regular json request.
               exit(json_encode($Data));
            }
            break;
//         case DELIVERY_METHOD_XHTML:
//            Gdn_ExceptionHandler($Ex);
//            break;
         case DELIVERY_METHOD_XML:
            header('Content-Type: text/xml', TRUE);
            array_map('htmlspecialchars', $Data);
            exit("<Exception><Code>{$Data['Code']}</Code><Class>{$Data['Class']}</Class><Message>{$Data['Exception']}</Message></Exception>");
            break;
         default:
            header('Content-Type: text/plain', TRUE);
            exit($Ex->getMessage());
      }
   }
739919
protected function renderXmlErrorMessage(Exception $exception)
    {
        $xml = "<error>\n  <message>Slim Application Error</message>\n";
        if ($this->displayErrorDetails) {
            do {
                $xml .= "  <exception>\n";
                $xml .= "    <type>" . get_class($exception) . "</type>\n";
                $xml .= "    <code>" . $exception->getCode() . "</code>\n";
                $xml .= "    <message>" . $this->createCdataSection($exception->getMessage()) . "</message>\n";
                $xml .= "    <file>" . $exception->getFile() . "</file>\n";
                $xml .= "    <line>" . $exception->getLine() . "</line>\n";
                $xml .= "    <trace>" . $this->createCdataSection($exception->getTraceAsString()) . "</trace>\n";
                $xml .= "  </exception>\n";
            } while ($exception = $exception->getPrevious());
        }
        $xml .= "</error>";

        return $xml;
    }
1024952
public function render_html_error_email( $exception, CssToInlineStyles $inliner = null ) {
		$plates = _soter_instance( 'plates' );
		$html = $plates->render( 'emails/html/error.php', [
			'message' => $exception->getMessage(),
		] );
		$css = $plates->render( 'emails/style.css' );
		$inliner = $inliner ?: new CssToInlineStyles();

		return $inliner->convert( $html, $css );
	}
25937
protected function echoExceptionWeb($exception)
    {
        $statusCode = ($exception instanceof WithHttpStatusInterface) ? $exception->getStatusCode() : 500;
        $statusMessage = ResponseInformationHelper::getStatusMessageByCode($statusCode);
        if (!headers_sent()) {
            header(sprintf('HTTP/1.1 %s %s', $statusCode, $statusMessage));
        }

        if (!isset($this->renderingOptions['templatePathAndFilename'])) {
            $this->renderStatically($statusCode, $exception);
            return;
        }

        try {
            echo $this->buildView($exception, $this->renderingOptions)->render();
        } catch (\Throwable $throwable) {
            $this->renderStatically($statusCode, $throwable);
        }
    }
668794
private function toJson(ClientErrorsException $exception)
  {
    Rest::response()->json([
      'status' => $exception->getMessage(),
      'code'   => $exception->getStatusCode()
    ], $exception->getStatusCode());
  }
174868
private function toJson(ServerErrorsException $exception)
  {
    Rest::response()->json([
      'status' => $exception->getMessage(),
      'code'   => $exception->getStatusCode()
    ], $exception->getStatusCode());
  }
741744
public function handleException(\Exception $exception)
    {
        $isAjax = !empty($_SERVER['HTTP_X_REQUESTED_WITH']);

        if ($isAjax) {

            $sEngine = Response\Factory::ENGINE_API;
            $sFormat = Response\Factory::FORMAT_JSON;
            $content = json_encode($exception->getTraceAsString());
        } else {
            $sEngine = Response\Factory::ENGINE_TEMPLATE;
            $sFormat = Response\Factory::FORMAT_HTML;

            if (EKA_ENV !== 'prod') {
                $contentHtml = '<b>Exception[' . $exception->getCode() . ']: ' . $exception->getMessage() . '</b><pre>' . $exception->getTraceAsString() . '</pre>';
            }

            $layoutPath = Config::getInstance()->get('Eureka\Global\Theme\php\layout');
            $themeName  = Config::getInstance()->get('Eureka\Global\Theme\php\theme');
            $content    = new Template($layoutPath . '/Template/' . $themeName . '/Main');
            $content->setVar('content', $contentHtml);
            $content->setVar('meta', Config::getInstance()->get('meta'));
        }

        $response = Response\Factory::create($sFormat, $sEngine);
        $response->setHttpCode(500)->setContent($content)->send();
    }