From 1ff5c35de5dbd70a782875a91dd2232fd01b002b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:38:04 +0200 Subject: Adding upstream version 0.10.1. Signed-off-by: Daniel Baumann --- vendor/ipl/html/src/Error.php | 117 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 vendor/ipl/html/src/Error.php (limited to 'vendor/ipl/html/src/Error.php') diff --git a/vendor/ipl/html/src/Error.php b/vendor/ipl/html/src/Error.php new file mode 100644 index 0000000..a4ab253 --- /dev/null +++ b/vendor/ipl/html/src/Error.php @@ -0,0 +1,117 @@ +addHtml(Html::tag('pre', $error->getTraceAsString())); + } + + return $result; + } + + /** + * + * @param Exception|Throwable|string $error + * @return string + */ + public static function render($error) + { + return static::show($error)->render(); + } + + /** + * @param bool|null $show + * @return bool + */ + public static function showTraces($show = null) + { + if ($show !== null) { + self::$showTraces = (bool) $show; + } + + return self::$showTraces; + } + + /** + * @deprecated Use {@link get_php_type()} instead + */ + public static function getPhpTypeName($any) + { + return get_php_type($any); + } + + /** + * @param Exception|Throwable $exception + * @return string + */ + protected static function createMessageForException($exception) + { + $file = preg_split('/[\/\\\]/', $exception->getFile(), -1, PREG_SPLIT_NO_EMPTY); + $file = array_pop($file); + return sprintf( + '%s (%s:%d)', + $exception->getMessage(), + $file, + $exception->getLine() + ); + } + + /** + * @param string + * @return HtmlDocument + */ + protected static function renderErrorMessage($message) + { + $output = new HtmlDocument(); + $output->addHtml( + Html::tag('div', ['class' => 'exception'], [ + Html::tag('h1', [ + Html::tag('i', ['class' => 'icon-bug']), + // TODO: Translate? More hints? + 'Oops, an error occurred!' + ]), + Html::tag('pre', $message) + ]) + ); + + return $output; + } +} -- cgit v1.2.3