This was posted at Caliburn.Micro discussions also. I'm really looking for advice and opinions on the best way to solve.
Say I have the following Action
public IEnumerable<IResult> SaveStation()
{
yield return Busy.MakeBusy();
yield return new StationSave(_station);
yield return Busy.MakeNotBusy();
yield return Show.Tab<StationBrowseViewModel>();
}
StationSave is an IResult wrapper around a simple (WCF) service invocation. The service uses FaultContract/FaultException for failures.
In the case of a fault, the user needs to be notified and the FaultContract will contain some useful info about what went wrong. Currently the Save result catches the exception and inserts it into ResultCompletionEventArgs of the Completed event. By doing so, the SequentialResult created by the pipeline is cancelled (because of the error), thus leaving the screen in a Busy state.
What I'm really after is ideas about the best way to recover from the error (remove the busy state) and notify the user (I have a couple of IResult implementations for different styles of notification which I would like to use) of the details provided in the fault contract. By attaching to the Completed event in my VM I can get the error, but at this point I am no longer in the context of the Action pipeline so any IResults I would like to use (the MakeNotBusy and my show notification implementation) I have to execute manually (and I'd have to new up my own ActionExecutionContext which I don't want to be doing).
I have had a look at Marco Amendola's rescue filter for Caliburn.Micro from here, but again I can't pass back IResults from the Rescue method.
Have I missed something obvious? How do others handle this situation?
Both Rob Eisenberg and Marco Amendola have provided possible solutions in the CodePlex forum.
I have chosen to take Marco's
RescueAttribute
from his filters implementation and modify it slightly to allow execution of furtherIResult
from the rescue method. This is the required change toRescueAttribute.HandleException
this allows the following in my VM: