-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Currently, prooph wraps exceptions that occur in the handler itself inside 2 exceptions
See:
This has some disadvantages:
- Middlewares can not react directly on messages that the handler (or subsequent methods in that handle) throws without some additional middleware unpacking it first. This wouldn't be very performant i guess and brings its own challanges. For example you need to be sure your unpacking handler is always configured to be after the CommandMiddleware. And additionally...
- ... you don't know if that message is representing an error that actual happened in proophs service-bus or http-middleware or your own code or code from other libraries.
If you use the service-bus, every exception is wrapped into a prooph-exception, making it very hard to discern between messages originating from your business code or from the prooph library itself.
Also the exception messages are 'dispatch failed' or 'error occured during dispatch'. I don't want to create a huge discussion about naming but i think this also shows that prooph shouldn't wrap them in the first place, because in my opinion, the message dispatch is successful as soon as the handler was found and invoked. Everything after that is not part of the service-bus' dispatching. But thats just more of a side-note or an indicator for me and shouldn't be the main point of discussion.
It's hard to use the middleware approach when a library is suddenly masking every exception you throw (at least when using the command-middleware/service-bus).
I think it would make sense for the service-bus and the command middleware to get more out of the way here and let that are not originated from prooph's own code flow more freely. Prooph has no chance of handling exceptions from business logic from the user of the lib anyway because they mean anything and are out of proophs scope.
Edit: this issue's scope is prooph/service-bus (the first lib that wraps the exception) and also of prooph/http-middleware (that wraps the already wrapped exception again). If we decide to act we should create another separate issue for prooph/service-bus.
