forked from GNUsocial/gnu-social
[CORE][Log] Add Log::unexpected_exception utility which logs and throws a ServerException
This commit is contained in:
parent
085e880631
commit
38a331220f
@ -31,6 +31,7 @@
|
||||
|
||||
namespace App\Core;
|
||||
|
||||
use App\Util\Exception\ServerException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
abstract class Log
|
||||
@ -42,6 +43,13 @@ abstract class Log
|
||||
self::$logger = $l;
|
||||
}
|
||||
|
||||
public static function unexpected_exception(\Exception $e)
|
||||
{
|
||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
|
||||
self::critical('Unexpected exception of class: "' . get_class($e) . '" was thrown in ' . get_called_class() . '::' . $backtrace[1]['function']);
|
||||
throw new ServerException('Unexpected exception', 500, $e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple static wrappers around Monolog's functions
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user