This commit is contained in:
2023-04-17 00:41:30 +08:00
parent 3b92bdb3ea
commit ac2f2654a3
+5 -10
View File
@@ -35,16 +35,10 @@ class ErrorHandler extends Component implements ErrorInterface
public string $category = 'app';
/**
* @var EventDispatch
*/
#[Container(EventDispatch::class)]
public EventDispatch $dispatch;
/**
* @param array|Closure|null $callback
* @return void
* @throws ReflectionException
*/
public function registerExceptionHandler(null|array|Closure $callback): void
{
@@ -60,6 +54,7 @@ class ErrorHandler extends Component implements ErrorInterface
/**
* @param array|Closure|null $callback
* @return void
* @throws ReflectionException
*/
public function registerErrorHandler(null|array|Closure $callback): void
{
@@ -107,7 +102,7 @@ class ErrorHandler extends Component implements ErrorInterface
$message = array_shift($messages);
$this->dispatch->dispatch(new Kiri\Events\OnSystemError());
Kiri::getDi()->get(EventDispatch::class)->dispatch(new Kiri\Events\OnSystemError());
$this->sendError($message, $lastError['file'], $lastError['line']);
}
@@ -124,7 +119,7 @@ class ErrorHandler extends Component implements ErrorInterface
{
$this->category = 'exception';
$this->dispatch->dispatch(new Kiri\Events\OnSystemError());
Kiri::getDi()->get(EventDispatch::class)->dispatch(new Kiri\Events\OnSystemError());
$this->sendError($exception->getMessage(), $exception->getFile(), $exception->getLine());
}
@@ -150,7 +145,7 @@ class ErrorHandler extends Component implements ErrorInterface
\Kiri::getLogger()->error('On error handler', [$data]);
$this->dispatch->dispatch(new Kiri\Events\OnSystemError());
Kiri::getDi()->get(EventDispatch::class)->dispatch(new Kiri\Events\OnSystemError());
throw new \ErrorException($error[1], $error[0], 1, $error[2], $error[3]);
}