Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support classes for exception map in ExceptionResponder #60

Open
vjik opened this issue Jun 14, 2022 · 0 comments
Open

Add support classes for exception map in ExceptionResponder #60

vjik opened this issue Jun 14, 2022 · 0 comments

Comments

@vjik
Copy link
Member

vjik commented Jun 14, 2022

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().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant