mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-17 22:05:35 +08:00
28 lines
689 B
PHP
28 lines
689 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace SPC\exception;
|
|
|
|
class ExceptionHandler
|
|
{
|
|
protected mixed $whoops = null;
|
|
|
|
private static ?ExceptionHandler $obj = null;
|
|
|
|
public static function getInstance(): ExceptionHandler
|
|
{
|
|
if (self::$obj === null) {
|
|
self::$obj = new self();
|
|
}
|
|
return self::$obj;
|
|
}
|
|
|
|
public function handle(\Throwable $e): void
|
|
{
|
|
logger()->error('Uncaught ' . get_class($e) . ': ' . $e->getMessage() . ' at ' . $e->getFile() . '(' . $e->getLine() . ')');
|
|
logger()->error($e->getTraceAsString());
|
|
logger()->critical('You can report this exception to static-php-cli GitHub repo.');
|
|
}
|
|
}
|