Skip to content

Add support classes for exception map in ExceptionResponder #60

@vjik

Description

@vjik

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions