ExceptionService unexpected behavior

Topics: Issues / bugs
Jan 8, 2013 at 3:29 PM
Edited Jan 8, 2013 at 3:29 PM

Hi, i use the following code to handle exceptions in my application. but in this way the exception first goes in visual studio (Unhandled exception) and then if i press Continue the Messagebox will be shown.

 

var serviceLocator = ServiceLocator.Default;

serviceLocator.RegisterType<IExceptionService, ExceptionService>();
serviceLocator.RegisterType<IMessageService, MessageService>();
var exceptionService = serviceLocator.ResolveType<IExceptionService>();
var messageService = serviceLocator.ResolveType<IMessageService>();
exceptionService.Register<DbUpdateException>(exception => messageService.Show("Error"));

 

i use exception service in this way:

 

private void OnDeleteExecute()
{
       var exceptionService = GetService<IExceptionService>();
       var messageService = GetService<IMessageService>();
       if (messageService.Show(SR.GlobalMessagesResource.AreYouSureToDelete, SR.ControlsResource.Warning, MessageButton.YesNo, MessageImage.Question) == MessageResult.Yes)
       {
           exceptionService.Process(() =>
           {
               context.Producers.Remove(SelectedProducer);
               context.SaveChanges();
           });
      }
}
Jan 10, 2013 at 8:36 PM

This is because you have break on all exceptions to true. Therefore visual studio breaks on it, but it will still work, right?