mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-21 23:55:35 +08:00
32 lines
826 B
PHP
32 lines
826 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace ZM\Exception;
|
||
|
|
|
||
|
|
use OneBot\Driver\ExceptionHandler;
|
||
|
|
use Throwable;
|
||
|
|
|
||
|
|
class Handler extends ExceptionHandler
|
||
|
|
{
|
||
|
|
public function __construct()
|
||
|
|
{
|
||
|
|
// 我们知道此处没有调用父类的构造函数,这是设计上的缺陷
|
||
|
|
// 将会在稍后修复
|
||
|
|
}
|
||
|
|
|
||
|
|
public function handle(Throwable $e): void
|
||
|
|
{
|
||
|
|
if ($e instanceof ZMKnownException) {
|
||
|
|
// 如果是已知异常,则可以输出问题说明和解决方案
|
||
|
|
// TODO
|
||
|
|
}
|
||
|
|
|
||
|
|
if (is_null($this->whoops)) {
|
||
|
|
ob_logger()->error('Uncaught ' . get_class($e) . ': ' . $e->getMessage() . ' at ' . $e->getFile() . '(' . $e->getLine() . ')');
|
||
|
|
ob_logger()->error($e->getTraceAsString());
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// $this->whoops->handleException($e);
|
||
|
|
}
|
||
|
|
}
|