X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2FUtils.php;h=bc1c9f5d6133b67eacc321b3d41da57f60b0f38d;hb=820cae27cfcc94af552818f3f1e5342e00478f6c;hp=7a9d264556213e09bd173508ecf6c63c3cc41553;hpb=b38a1b0209f546d4824a0db81a34c4e30fcdebaf;p=github%2Fshaarli%2FShaarli.git diff --git a/application/Utils.php b/application/Utils.php index 7a9d2645..bc1c9f5d 100644 --- a/application/Utils.php +++ b/application/Utils.php @@ -465,3 +465,12 @@ function t($text, $nText = '', $nb = 1, $domain = 'shaarli') { return dn__($domain, $text, $nText, $nb); } + +/** + * Converts an exception into a printable stack trace string. + */ +function exception2text(Throwable $e): string +{ + return $e->getMessage() . PHP_EOL . $e->getFile() . $e->getLine() . PHP_EOL . $e->getTraceAsString(); +} +