Gets the full HTML content associated with the given exception.

@param \Exception|FlattenException $exception An \Exception or FlattenException instance

@return string The HTML content as a string
185893
public function getHtml($exception)
    {
        if (!$exception instanceof FlattenException) {
            $exception = FlattenException::create($exception);
        }

        return $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
    }
819664
protected function format_exception( Exception $exception ) {
		$string = get_class( $exception );

		if ( ! empty( $exception->getMessage() ) ) {
			$string .= " : {$exception->getMessage()}";
		}

		if ( ! empty( $exception->getCode() ) ) {
			$string .= " (#{$exception->getCode()})";
		}

		return $string;
	}
612050
public function convertExceptionToHtml($exception)
    {
        $flat = $this->getFlattenedException($exception);

        $handler = new SymfonyExceptionHandler();

        return $this->decorate($handler->getContent($flat), $handler->getStylesheet($flat), $flat);
    }
670455
protected function getExceptionExamplePosition(Exception $exception)
    {
        $refl = $exception->getCause();
        foreach ($exception->getTrace() as $call) {
            if (!isset($call['file'])) {
                continue;
            }

            if (!empty($refl) && $refl->getFilename() === $call['file']) {
                return array($call['file'], $call['line']);
            }
        }

        return array($exception->getFile(), $exception->getLine());
    }
1314580
protected function _getMessage(Exception $exception)
    {
        $message = $this->getMessageForException($exception);

        $request = Router::getRequest();
        if ($request) {
            $message .= $this->_requestContext($request);
        }

        return $message;
    }
1302051
protected function getErrorCodeFromServiceException(ServiceException $exception)
    {
        $xml = @simplexml_load_string($exception->getResponse()->getBody());

        if ($xml && isset($xml->Code)) {
            return (string) $xml->Code;
        }

        return $exception->getErrorText();
    }
474311
private function getExceptionData($exception)
    {
        $data = [];

        $data['host'] = Request::server('HTTP_HOST');
        $data['method'] = Request::method();
        $data['fullUrl'] = Request::fullUrl();
        if (php_sapi_name() === 'cli') {
            $data['host'] = parse_url(config('app.url'), PHP_URL_HOST);
            $data['method'] = 'CLI';
        }
        $data['exception'] = $exception->getMessage();
        $data['error'] = $exception->getTraceAsString();
        $data['line'] = $exception->getLine();
        $data['file'] = $exception->getFile();
        $data['class'] = get_class($exception);
        $data['storage'] = array(
            'SERVER'  => Request::server(),
            'GET'     => Request::query(),
            'POST'    => $_POST,
            'FILE'    => Request::file(),
            'OLD'     => Request::hasSession() ? Request::old() : [],
            'COOKIE'  => Request::cookie(),
            'SESSION' => Request::hasSession() ? Session::all() : [],
            'HEADERS' => Request::header(),
        );

        // Remove empty, false and null values
        $data['storage'] = array_filter($data['storage']);

        // Censor sensitive field values
        array_walk_recursive($data['storage'], 'self::censorSensitiveFields');

        $count = $this->config['count'];
        
        $data['exegutor']   = [];
        $data['file_lines'] = [];
        
        $file = new SplFileObject($data['file']);
        for ($i = -1 * abs($count); $i <= abs($count); $i++) {
            list($line, $exegutorLine) = $this->getLineInfo($file, $data['line'], $i);
            if (!$line && !$exegutorLine) {
                continue;
            }
            $data['exegutor'][] = $exegutorLine;
            $data['file_lines'][$data['line'] + $i] = $line;
        }

        // to make Symfony exception more readable
        if ($data['class'] == 'Symfony\Component\Debug\Exception\FatalErrorException') {
            preg_match("~^(.+)' in ~", $data['exception'], $matches);
            if (isset($matches[1])) {
                $data['exception'] = $matches[1];
            }
        }

        return $data;
    }
172355
protected function getStatusCode(Exception $exception)
    {
        if ($exception instanceof ValidationException) {
            return $exception->status;
        }

        return $this->getExceptionStatusCode($exception);
    }
301295
private function exceptionHtml(\Exception $e)
    {
        $response = new Response();
        $html = $this->render("OwsProxy3CoreBundle::exception.html.twig", array("exception" => $e));
        $response->headers->set('Content-Type', 'text/html');
        $response->setStatusCode($e->getCode() ?: 500);
        $response->setContent($html->getContent());
        return $response;
    }
718021
private function getStatusCode(\Exception $exception)
    {
        $statusCode = $this->default['status'];

        if ($exception instanceof SymfonyHttpExceptionInterface
            || $exception instanceof HttpExceptionInterface
        ) {
            $statusCode = $exception->getStatusCode();
        }

        return $statusCode;
    }
444016
protected function getExceptionAsXml(Throwable $exception): string
	{
		$details = $this->getStatusCodeAndMessage($exception);

		$xml = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><error />");

		$xml->addChild('code', $details['code']);

		$xml->addChild('message', $details['message']);

		return $xml->asXML();
	}
936616
public function transform(Exception $exception)
    {
        if ($exception instanceof ModelNotFoundException) {
            $exception = new NotFoundHttpException($exception->getMessage(), $exception, $exception->getCode());
        }

        return $exception;
    }
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;
    }
195230
protected function showXML($exception) {
		$endline = "\r\n";
		$xml = '<?xml version="1.0" encoding="UTF-8"?>'.$endline.
				'<response>'.$endline.
					'<status>error</status>'.$endline.
					'<message>'.htmlspecialchars($this->getMessageForUser($exception)).'</message>'.$endline.
				'</response>';

		header('Content-Type: application/xml; charset=utf-8');
		echo $xml;
	}
1235137
public static function displayException(Throwable $exception, $html = NULL) {
        if($html === NULL) {
            $html = isset($_SERVER["REQUEST_METHOD"]);
        }

        if($html) {
            http_response_code(500);
            ?><!DOCTYPE html>
<html>
<head>
    <title>Whooops!</title>
</head>
<body>
    <h1>Whooops!</h1>
    <p>I caught an exception. Can I keep it?</p>
    <h2><?php echo get_class($exception); ?></h2>
    <p><?php echo $exception->getMessage(); ?></p>
    <h3>Location:</h3>
    <p>
        Line <?php echo $exception->getLine(); ?><br>
        <?php echo $exception->getFile(); ?><br>
    </p>
    <h3>Trace:</h3>
    <pre><?php echo $exception->getTraceAsString(); ?></pre>
</body>
</html><?php
        }
        else {
            $width = 80;

            $message = call_user_func_array("array_merge", array_map(function($a) use ($width) { return str_split($a, $width-4); }, explode("\n", $exception->getMessage())));
            $eline = call_user_func_array("array_merge", array_map(function($a) use ($width) { return str_split($a, $width-12); }, explode("\n", $exception->getLine())));
            $file = call_user_func_array("array_merge", array_map(function($a) use ($width) { return str_split($a, $width-12); }, explode("\n", $exception->getFile())));
            $trace = call_user_func_array("array_merge", array_map(function($a) use ($width) { return str_split($a, $width-6); }, explode("\n", $exception->getTraceAsString())));

            foreach($eline as $key => $value) {
                $eline[$key] = $key ? "      │ $value" : "Line: │ $value";
            }

            foreach($file as $key => $value) {
                $file[$key] = $key ? "      │ $value" : "File: │ $value";
            }

            $len = max(array_map("mb_strlen", array_merge($message, $eline, $file, ["Trace:"], $trace)))+6;

            echo "╔".str_repeat("═", $len-2)."╗\n";
            foreach($message as $line) {
                echo "║ $line".str_repeat(" ", $len - mb_strlen($line) - 4)." ║\n";
            }
            echo "╠═══════╤".str_repeat("═", $len-10)."╣\n";
            foreach($file as $line) {
                echo "║ $line".str_repeat(" ", $len - mb_strlen($line) - 4)." ║\n";
            }
            echo "╟───────┼".str_repeat("─", $len-10)."╢\n";
            foreach($eline as $line) {
                echo "║ $line".str_repeat(" ", $len - mb_strlen($line) - 4)." ║\n";
            }
            echo "╟───────┴".str_repeat("─", $len-10)."╢\n";
            echo "║ Trace:".str_repeat(" ", $len-9)."║\n";
            echo "║".str_repeat(" ", $len-2)."║\n";
            foreach($trace as $line) {
                echo "║   $line".str_repeat(" ", $len - mb_strlen($line) - 5)."║\n";
            }
            echo "╚".str_repeat("═", $len-2)."╝\n";
        }
    }
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);
        }
    }
436119
protected function echoExceptionWeb($exception)
    {
        $statusCode = ($exception instanceof WithHttpStatusInterface) ? $exception->getStatusCode() : 500;
        $statusMessage = ResponseInformationHelper::getStatusMessageByCode($statusCode);
        $referenceCode = ($exception instanceof WithReferenceCodeInterface) ? $exception->getReferenceCode() : null;
        if (!headers_sent()) {
            header(sprintf('HTTP/1.1 %s %s', $statusCode, $statusMessage));
        }

        try {
            if (isset($this->renderingOptions['templatePathAndFilename'])) {
                try {
                    echo $this->buildView($exception, $this->renderingOptions)->render();
                } catch (\Throwable $throwable) {
                    $this->renderStatically($statusCode, $throwable);
                }
            } else {
                echo $this->renderStatically($statusCode, $referenceCode);
            }
        } catch (\Exception $innerException) {
            $message = $this->throwableStorage->logThrowable($innerException);
            $this->logger->critical($message);
        }
    }