I am trying to have my page call a method and, if it fails, display an error in my mbResult control. However, since my method is a void method, I am having a hard time throwing the exception. If I throw it from the method end it will not display in my error box.
I have the following code in my my page:
try
{
Facade.AcceptChanges();
}
catch(FarAlreadyExistsException)
{
mbResult.Message = new MessageInfo(FutureActivitiesAlreadyExistsMessage);
return;
}
the accept changes method is this
public void AcceptChanges()
{
try
{
DataContext.SaveChanges();
}
catch (Exception)
{
return;
}
}
Remove the second try-catch to let the exception get caught in your first catch block:
EDIT: It seems you should also apply the following change: