-
-
Notifications
You must be signed in to change notification settings - Fork 17
Description
It can make several ways.
One / Container + Callable
Configuration:
$exceptionMap = [
MyNotFoundException::class => MyExceptionHandler::class,
];
Handling: get MyExceptionHandler
class from container and run as callable (use __invoke()
) via injector.
Two / Container + Interface
Configuration:
$exceptionMap = [
MyNotFoundException::class => MyExceptionHandler::class,
];
Add new interface ExceptionHandlerInterface
with method createResponse(Throwable $e): ResponseInterface
.
Handling: get MyExceptionHandler
class from container and run createResponse()
.
Three / Array Definition + Callable
Add support of array definitions:
$exceptionMap = [
MyNotFoundException::class => [
'class' => MyExceptionHandler::class,
'__construct()' => [ ... ],
],
];
Handling: resolve array definition via yiisoft/definitions
and run as callable (use __invoke()
) via injector.
Four / Array Definition + Interface
Add support of array definitions:
$exceptionMap = [
MyNotFoundException::class => [
'class' => MyExceptionHandler::class,
'__construct()' => [ ... ],
],
];
Add new interface ExceptionHandlerInterface
with method createResponse(Throwable $e): ResponseInterface
.
Handling: resolve array definition via yiisoft/definitions
and run createResponse()
.