8000 [Messenger] Add possibility to disable HandleFailedException for specific bus · Issue #35427 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[Messenger] Add possibility to disable HandleFailedException for specific bus #35427
Closed
@alexander-schranz

Description

@alexander-schranz

Description

I'm using the messenger component as a sync bus. Its similiar to the HandleTrait.
Since Messenger 4.3 the messenger bus wraps all exception in a HandleFailedException. So if my handler for example throws a EntityNotFoundException that EntityNotFoundException will get wrapped by the HandleFailedException and so I'm not able to catch directly the EntityNotFoundException in the service which did call dispatch.

Example

try {
    $this->messageBus->dispatch(new ModifyEventMessage($id)); // Handler can throws a EntityNotFoundException
} catch (EntityNotFoundException $e) {
    // never called
}

instead I would need currently do something like:

try {
    try {
        $this->messageBus->dispatch(new ModifyEventMessage($id)); // Handler can throws a EntityNotFoundException
    } catch (HandleFailedException $e) {
        /** @var \Throwable $previous */
        $previous = $e->getPrevious();

        throw $previous;
    }
} catch (EntityNotFoundException $e) {
    // ...
}

It would be great if there is a configuraiton which make it possible to disable that the real exception is thrown instead of the HandleFailedException. Hints welcome how this could be implemented.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0