Get the HTML content associated with the given exception.

@param \Exception $exception
@param int        $code

@return string
773570
public function display(Exception $exception, $code)
    {
        // Collect some info about the exception.
        $info = $this->info($code, $exception);

        // Is the current request an AJAX request?
        if ((boolean)($this->request instanceof Request && $this->request->wantsJson()) == true) {
            $json_object = (object)[ 'error' => [
                'type'    => 'Exception',
                'message' => $info['message'],
            ] ];

            return JsonResponse::create($json_object, $code);
        }

        // For model-not-found, use 404 errors.
        if ($exception instanceof ModelNotFoundException) {
            $code = 404;
        }

        // If there is a custom view, use that.
        if ($this->view->exists("errors.{$code}")) {
            return $this->view->make("errors.{$code}", $info)->render();
        }

        // If the configured default error view (or errors.error) exists, render that.
        if (($errorview = $this->config->get('view.error', 'errors.error')) && $this->view->exists($errorview)) {
            return $this->view->make($errorview, $info)->render();
        }

        // Last resort: simply show the error code and message.
        return new Response($this->getFallbackDisplay($code, $info['name'], $info['message']), $code);
    }
850982
private function formatException(\Exception $exception)
    {
        $result = [
            'message' => $exception->getMessage(),
            'type'      => get_class($exception),
            'code'      => $exception->getCode(),
            'trace' => [
                [
                    'file' => $exception->getFile() ?: 'unknown',
                    'line' => $exception->getLine() ?: 'unknown',
                ]
            ]
        ];

        foreach ($exception->getTrace() as $frame) {
            $result['trace'][] = $this->formatStackFrame($frame);
        }

        if ($previous = $exception->getPrevious()) {
            $result['previous'] = $this->formatException($previous);
        }

        return $result;
    }
156547
public function getCode(FlattenException $exception)
    {
        if (method_exists($exception, 'getStatusCode') == true) {
            $code = $exception->getStatusCode();
        } else {
            $code = $exception->getCode();
        }

        return $code;
    }
718021
private function getStatusCode(\Exception $exception)
    {
        $statusCode = $this->default['status'];

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

        return $statusCode;
    }
360110
protected function _code(Exception $exception)
    {
        $code = 500;

        $exception = $this->_unwrap($exception);
        $errorCode = $exception->getCode();
        if ($errorCode >= 400 && $errorCode < 600) {
            $code = $errorCode;
        }

        return $code;
    }
626635
protected function renderHtmlExceptionOrError($exception)
    {
        if (!$exception instanceof Exception && !$exception instanceof \Error) {
            throw new RuntimeException("Unexpected type. Expected Exception or Error.");
        }

        $html = sprintf('<div><strong>Type:</strong> %s</div>', get_class($exception));

        if (($code = $exception->getCode())) {
            $html .= sprintf('<div><strong>Code:</strong> %s</div>', $code);
        }

        if (($message = $exception->getMessage())) {
            $html .= sprintf('<div><strong>Message:</strong> %s</div>', htmlentities($message));
        }

        if (($file = $exception->getFile())) {
            $html .= sprintf('<div><strong>File:</strong> %s</div>', $file);
        }

        if (($line = $exception->getLine())) {
            $html .= sprintf('<div><strong>Line:</strong> %s</div>', $line);
        }

        if (($trace = $exception->getTraceAsString())) {
            $html .= '<h2>Trace</h2>';
            $html .= sprintf('<pre>%s</pre>', htmlentities($trace));
        }

        return $html;
    }
957799
protected function getItemTextMessage($exception)
    {
    	$text = sprintf('Type: %s' . PHP_EOL, get_class($exception));
    	
    	if (($code = $exception->getCode())) {
    		$text .= sprintf('Code: %s' . PHP_EOL, $code);
    	}
    	
    	if (($message = $exception->getMessage())) {
    		$text .= sprintf('Message: %s' . PHP_EOL, htmlentities($message));
    	}
    	
    	if (($file = $exception->getFile())) {
    		$text .= sprintf('File: %s' . PHP_EOL, $file);
    	}
    	
    	if (($line = $exception->getLine())) {
    		$text .= sprintf('Line: %s' . PHP_EOL, $line);
    	}
    	
    	if (($trace = $exception->getTraceAsString())) {
    		$text .= sprintf('Trace: ' . PHP_EOL. '%s', $trace);
    	}
    	
    	return $text;
    }
652525
protected function getXmlMessage($exception)
    {
        $xml = "<error>\n  <message>Application Error</message>\n";
        if ($this->options['display_details']) {
            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;
    }
1181563
protected function renderHtmlErrorMessage(Exception $exception)
    {
        $title = 'Slim Application Error';

        if ($this->displayErrorDetails) {
            $html = '<p>The application could not run because of the following error:</p>';
            $html .= '<h2>Details</h2>';
            $html .= $this->renderHtmlException($exception);

            while ($exception = $exception->getPrevious()) {
                $html .= '<h2>Previous exception</h2>';
                $html .= $this->renderHtmlExceptionOrError($exception);
            }
        } else {
            $html = '<p>A website error has occurred. Sorry for the temporary inconvenience.</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;
    }
1309035
private function getMessage(\Exception $exception)
    {
        $message = $exception->getMessage();

        if ($this->isApiException($exception)) {
            $message = $exception->getMessageWithVariables();
        }

        return $message;
    }
692034
static protected function formatExceptionMessage(\Exception $exception)
    {

        $errorFullText = '<div><b>New ' . get_class($exception) . '</b></div>';
        $errorFullText .= '<div><b>File:</b> ' . $exception->getFile() . '</div>';
        $errorFullText .= '<div><b>Line:</b> ' . $exception->getLine() . '</div>';
        $errorFullText .= '<div><b>Message:</b> ' . $exception->getMessage() . '</div>';

        $trace = $exception->getTrace();

        if (get_class($exception) != 'DebugException') {
            array_unshift($trace, array('file' => $exception->getFile(), 'line' => $exception->getLine(), 'function' => 'throw ' . get_class($exception), 'args' => array($exception->getMessage(), $exception->getCode())));
        }

        $traceString = '';
        foreach ($trace as $tTraceItem) {

            if (empty ($tTraceItem ['file'])) {
                $tTraceItem ['file'] = '';
            }
            if (empty ($tTraceItem ['line'])) {
                $tTraceItem ['line'] = '';
            }

            $traceString .= '<li>' . basename($tTraceItem ['file']) . " at line #" . $tTraceItem ['line'] . "\t";
            if (isset ($tTraceItem ['class'])) {
                $traceString .= $tTraceItem ['class'] . '::' . $tTraceItem ['function'] . '(';
            } elseif (isset ($tTraceItem ['function'])) {
                $traceString .= $tTraceItem ['function'] . '(';
            }

            if (!empty ($tTraceItem ['args'])) {
                $separator = '';
                foreach ($tTraceItem ['args'] as $arg) {
                    $traceString .= $separator . self::getArgument($arg);
                    $separator = ', ';
                }
                $traceString .= ')';
            }
            $traceString .= "</li>";
        }

        $errorFullText .= '<div><b>Backtrace:</b> <ul style="margin: 0.2em;">' . $traceString . '</ul></div>';

        return $errorFullText;
    }
983735
protected function info($code, Exception $exception)
    {
        $description = $exception->getMessage();
        $namespace   = 'winternight/laravel-error-handler';

        // If there is no error message for the given HTTP code, default to 500.
        if (!$this->lang->has("$namespace::messages.error.$code.name")) {
            $code = 500;
        }

        $name    = $this->lang->get("$namespace::messages.error.$code.name");
        $message = $this->lang->get("$namespace::messages.error.$code.message");

        return compact('code', 'name', 'message', 'description');
    }
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;
	}
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;
    }
1373995
public function getExceptionByCode($code)
    {
        $code       = (int) $code;
        $exceptions = array();
        foreach ($this->_exceptions as $e) {
            if ($code == $e->getCode()) {
                $exceptions[] = $e;
            }
        }

        if (empty($exceptions)) {
            $exceptions = false;
        }

        return $exceptions;
    }
1273913
public function render($request, Exception $exception)
    {
        if ($exception instanceof PlatformException) {
            return $exception->toResponse();
        }

        if ($exception instanceof ValidationException) {
            return $exception->toResponse();
        }

        if ($request->isJson() && $exception->getCode()) {
            return response()->json([
                'error' => [
                    'description' => $exception->getMessage(),
                    'stack'       => $exception->getTrace(),
                ],
            ], 500);
        }

        return parent::render($request, $exception);
    }
185893
public function getHtml($exception)
    {
        if (!$exception instanceof FlattenException) {
            $exception = FlattenException::create($exception);
        }

        return $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
    }