This commit is contained in:
2021-08-13 14:58:58 +08:00
parent 15851ba97c
commit 2432b98be5
13 changed files with 90 additions and 151 deletions
+5 -2
View File
@@ -14,7 +14,9 @@ use HttpServer\IInterface\IFormatter;
use Kiri\Abstracts\Component;
use Kiri\Core\Json;
use Kiri\Event;
use Kiri\Events\EventDispatch;
use Kiri\Kiri;
use Server\Events\OnAfterRequest;
/**
* Class ErrorHandler
@@ -74,7 +76,7 @@ class ErrorHandler extends Component implements ErrorInterface
{
$this->category = 'exception';
Event::trigger(Event::SYSTEM_RESOURCE_CLEAN);
di(EventDispatch::class)->dispatch(new OnAfterRequest());
$this->sendError($exception->getMessage(), $exception->getFile(), $exception->getLine());
}
@@ -99,7 +101,8 @@ class ErrorHandler extends Component implements ErrorInterface
Kiri::app()->error($data, 'error');
Event::trigger(Event::SYSTEM_RESOURCE_CLEAN);
di(EventDispatch::class)->dispatch(new OnAfterRequest());
throw new \ErrorException($error[1], $error[0], 1, $error[2], $error[3]);
}
+6 -6
View File
@@ -9,9 +9,9 @@ use JetBrains\PhpStorm\Pure;
use Server\SInterface\CustomProcess;
use Kiri\Core\Json;
use Kiri\Exception\ComponentException;
use Kiri\Process\Process;
use Kiri\Kiri;
use Swoole\Coroutine;
use Swoole\Process;
/**
@@ -24,7 +24,7 @@ class LoggerProcess implements CustomProcess
/**
* @return string
*/
#[Pure] public function getProcessName(\Swoole\Process $process): string
#[Pure] public function getProcessName(Process $process): string
{
// TODO: Implement getProcessName() method.
return get_called_class();
@@ -32,10 +32,10 @@ class LoggerProcess implements CustomProcess
/**
* @param \Swoole\Process $process
* @param Process $process
* @throws ComponentException
*/
public function onHandler(\Swoole\Process $process): void
public function onHandler(Process $process): void
{
// TODO: Implement onHandler() method.
$this->message($process);
@@ -43,11 +43,11 @@ class LoggerProcess implements CustomProcess
/**
* @param \Swoole\Process $process
* @param Process $process
* @throws ComponentException
* @throws Exception
*/
public function message(\Swoole\Process $process)
public function message(Process $process)
{
$message = Json::decode($process->read());
if (!empty($message)) {