Last post May 28, 2010 10:29 AM by ilmatte
May 28, 2010 04:02 AM|ilmatte|LINK
I'm wondering what's the preferred way to manage exceptions in an MVP implemented with a Passive View.
There's a discussion in my company about putting try/catch blocks in the presenter or only in the view.
In my opinion the logical top level caller is the presenter (even if the actual one is the view).
Moreover I can test the presenter and not the view. This is the reason why I prefer to define a method in the view interface:
and invoke it from the catch blocks in the presenter:
catch (Exception exception)
view.ShowError("An error occurred")
In this way the developers of future views can safely forget to implement exception handling but the IView interface force them
to implement a ShowError method.
The drawback is that if I want to feel completely safe I need to add redundant try/catch blocks in the view.
The other way would be to add try catch blocks only in the views and not introducing the showerror method in the view interface.
What do you suggest?
May 28, 2010 04:48 AMemail@example.com|LINK
this is very helpfull
May 28, 2010 10:29 AM|ilmatte|LINK
Thank you very much for your answer.
It seems to me that the person in the article you pointed out agrees with me.
In facti he is placing try catch blocks both in the presenter and in the view
providing the view with an Error property to be used by the presenter.
Any other opinions?