modify plugin name
This commit is contained in:
@@ -49,15 +49,35 @@ class ErrorHandler extends Component implements ErrorInterface
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 错误处理注册
|
* @param array|null $callback
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function register()
|
public function registerExceptionHandler(?array $callback): void
|
||||||
{
|
{
|
||||||
set_exception_handler([$this, 'exceptionHandler']);
|
set_exception_handler($callback ?? [$this, 'exceptionHandler']);
|
||||||
set_error_handler([$this, 'errorHandler']);
|
|
||||||
register_shutdown_function([$this, 'shutdown']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array|null $callback
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function registerErrorHandler(?array $callback): void
|
||||||
|
{
|
||||||
|
set_error_handler($callback ?? [$this, 'errorHandler']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array|null $callback
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function registerShutdownHandler(?array $callback): void
|
||||||
|
{
|
||||||
|
register_shutdown_function($callback ?? [$this, 'shutdown']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ use Symfony\Component\Console\{Application as ConsoleApplication,
|
|||||||
Output\OutputInterface
|
Output\OutputInterface
|
||||||
};
|
};
|
||||||
use Kiri\Di\LocalService;
|
use Kiri\Di\LocalService;
|
||||||
|
use Kiri\Exception\ConfigException;
|
||||||
|
use Kiri\Error\ErrorHandler;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,6 +45,21 @@ class Main extends BaseMain
|
|||||||
|
|
||||||
public string $state = '';
|
public string $state = '';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
* @throws ConfigException
|
||||||
|
*/
|
||||||
|
public function init(): void
|
||||||
|
{
|
||||||
|
$error = $this->container->get(ErrorHandler::class);
|
||||||
|
$error->registerShutdownHandler(Config::get('error.shutdown', []));
|
||||||
|
$error->registerExceptionHandler(Config::get('error.exception', []));
|
||||||
|
$error->registerErrorHandler(Config::get('error.error', []));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $service
|
* @param string $service
|
||||||
* @return $this
|
* @return $this
|
||||||
|
|||||||
Reference in New Issue
Block a user