diff options
Diffstat (limited to 'lib/visual.inc.php')
| -rw-r--r-- | lib/visual.inc.php | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/lib/visual.inc.php b/lib/visual.inc.php index 15b1c7d..3f25ace 100644 --- a/lib/visual.inc.php +++ b/lib/visual.inc.php @@ -485,31 +485,15 @@ function TransformInternalLinks($str){ /** * Displays the provided exception in a more readable fashion. * - * @param Exception $exception The exception to be displayed + * @param Throwable $exception The exception to be displayed * @param bool $as_html Indicates whether the exception shall be displayed as * plain text or html (optional, defaults to plain text) * @param bool $deep Indicates whether any previous exception should be * included in the output (optional, defaults to false) * @return String The exception display either as plain text or html */ -function display_exception($exception, $as_html = false, $deep = false) { - $result = ''; - $result .= sprintf("%s: %s\n", _('Typ'), get_class($exception)); - $result .= sprintf("%s: %s\n", _('Nachricht'), $exception->getMessage()); - $result .= sprintf("%s: %d\n", _('Code'), $exception->getCode()); - - $trace = sprintf(" #$ %s(%u)\n", $exception->getFile(), $exception->getLine()) - . ' ' . str_replace("\n", "\n ", $exception->getTraceAsString()); - $trace = str_replace($GLOBALS['STUDIP_BASE_PATH'] . '/', '', $trace); - $result .= sprintf("%s:\n%s\n", _('Stack trace'), $trace); - - if ($deep && $exception->getPrevious()) { - $result .= "\n"; - $result .= _('Vorherige Exception:') . "\n"; - $result .= display_exception($exception->getPrevious(), false, $deep); - } - - return $as_html ? nl2br(htmlReady($result)) : $result; +function display_exception(Throwable $exception, bool $as_html = false, bool $deep = false): string { + return ExceptionDisplay::from($exception)->display($as_html, $deep); } /** |
