8000 [Messenger] Make `HandleTrait` unwrap `HandlerFailedException` · Issue #52300 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Messenger] Make HandleTrait unwrap HandlerFailedException #52300

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

Open
MatTheCat opened this issue Oct 26, 2023 · 2 comments
Open

[Messenger] Make HandleTrait unwrap HandlerFailedException #52300

MatTheCat opened this issue Oct 26, 2023 · 2 comments

Comments

@MatTheCat
Copy link
Contributor
MatTheCat commented Oct 26, 2023

Description

The HandleTrait allows to use Messenger as a function call by enforcing a single handler being called and returning its result (cf. https://symfony.com/doc/current/messenger.html#getting-results-when-working-with-command-query-buses).

Still, if this handler throws an exception it will be wrapped in a HandlerFailedException. The latter is useful when multiple handlers are called, but it seems to me it just adds noise when using the HandleTrait.

Would it make sense to make HandleTrait::handle catch HandlerFailedExceptions and throw the wrapped exception instead?

Example

No response

@alexander-schranz
Copy link
Contributor

In our bus which we use we are also doing it via a middleware: https://github.com/sulu/messenger#unpackexceptionmiddleware, as that make it possible to catch our domain exception in the controllers/commands.

@MatTheCat
Copy link
Contributor Author
MatTheCat commented Dec 8, 2023

Such a middleware would allow to keep the BC, so… I hope you don’t mind but I’m stealing the idea 😁

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