xervice / exception-handler
2.0.0
2018-08-27 10:21 UTC
Requires
- php: >=7.1.0
- xervice/core: ^4.0.0
- xervice/kernel: ^2.0.0
Requires (Dev)
This package is auto-updated.
Last update: 2025-03-01 00:24:20 UTC
README
Installation
composer require xervice/exception-handler
Configuration
You have to add the ExceptionService to your kernel stack.
After that the defined registers will be executed. To define a register you have to overwrite the DependencyProvider:
<?php namespace App\ExceptionHandler; use Xervice\ExceptionHandler\ExceptionHandlerDependencyProvider as XerviceExceptionHandlerDependencyProvider; class ExceptionHandlerDependencyProvider extends XerviceExceptionHandlerDependencyProvider { /** * @return \Xervice\ExceptionHandler\Business\Model\Register\RegisterInterface[] */ public function getExceptionRegister(): array { return [ new MyExceptionRegister() // implements RegisterInterface ]; } }
You can define the default "ExceptionHandlerRegister". If you use it, you can define own ExceptionHandler. Every ExceptionHandler get automatically exexpected exceptions. You can define your ExceptionHandler also in the Dependency Provider.
<?php namespace App\ExceptionHandler; use Xervice\ExceptionHandler\ExceptionHandlerDependencyProvider as XerviceExceptionHandlerDependencyProvider; class ExceptionHandlerDependencyProvider extends XerviceExceptionHandlerDependencyProvider { /** * @return \Xervice\ExceptionHandler\Business\Model\Handler\ExceptionHandlerInterface[] */ public function getExceptionHandler(): array { return [ new MyExceptionHandler() // implements ExceptionHandlerInterface ]; } }
Usage
Also you can parse your own exception by using the Facade:
$exceptionHandlerFacade->handleException($exception); This will loop all defined ExceptionHandler with the given exception.