diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2025-02-27 19:47:17 +0000 |
|---|---|---|
| committer | David Siegfried <david.siegfried@uni-vechta.de> | 2025-02-27 19:47:17 +0000 |
| commit | ea81d27a628a4c4df304bc3465ee057eeed85f80 (patch) | |
| tree | a00f8a6ba4d7b35c13e2ee00d68c0da7864de177 /lib/visual.inc.php | |
| parent | 0896c2670d96dfe88c6a396ba4b333c547271a64 (diff) | |
allow file locations in displayed exceptions to be linked to your editor, fixes #5175
Closes #5175
Merge request studip/studip!3866
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); } /** |
