-
Notifications
You must be signed in to change notification settings - Fork 11
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
Dealing with exception handling from ViewModelAppenders inside a composition #375
Comments
Thanks for your question @Stephanvs and I'm happy that you're thinking about using ServiceComposer. I spent a lot thinking about exception handling and less important handlers and I couldn't find a solution that satisfied me without compromising on something. I'm leaning toward thinking that it's not ServiceComposer composer responsibility to deal with errors in handlers. Let me give you an overview of the whys:
Given that your code is the best place to understand if an error should bubble up or not, I have always preferred to have try/catch blocks in handlers where appropriate, instead of a generic mechanism to handle failing handlers. That being said. Change my mind! 😎😀 |
Hi Mauro,
We currently have a similar implementation of a ViewModel composition engine in our project. We're considering migrating to this libarary (just fyi 😉).
I was thinking about exception handling in a composition. Let's say a handful of services contribute to the composition of a complete page. If a single ViewModelAppender in the current implementation throws an exception, the whole composition 'fails' and returns an error status code/response, and we're unable to show anything to the end-user. At that moment we should retry the request or resort another alternative.
Some services only contribute a small feature, which might not be considered 'critical' or even important to show in the UI. We could easily just not show them if they failed.
What do you think about wrapping each ViewModelAppender's
Append
method with a try/catch block. For instance; in this linehttps://github.com/ServiceComposer/ServiceComposer.AspNetCore/blob/master/src/ServiceComposer.AspNetCore/CompositionHandler.cs#L146
Or do you have a strong reason not to do this specifically and have exceptions handled by the Appender itself?
I'm curious what you think about this and am looking forward to a response.
Regards,
Stephan
The text was updated successfully, but these errors were encountered: