/// <summary> /// Håndtering af exception ved udførelse af en kommando. /// </summary> /// <param name="exception">Exception.</param> /// <param name="parameter">Parameter, som kommanoden er blevet kaldt med.</param> protected override void HandleException(Exception exception, object parameter) { IntranetGuiCommandException commandException = null; IntranetGuiSystemException systemException = null; try { if (exception is IntranetGuiCommandException) { base.HandleException(exception, parameter); return; } if (exception is IntranetGuiValidationException) { commandException = new IntranetGuiCommandException(Resource.GetExceptionMessage(ExceptionMessage.ErrorPostingAccountingLine), exception.Message, this, parameter, exception); base.HandleException(commandException, parameter); return; } if (exception is IntranetGuiBusinessException) { commandException = new IntranetGuiCommandException(Resource.GetExceptionMessage(ExceptionMessage.ErrorPostingAccountingLine), exception.Message, this, parameter, exception); base.HandleException(commandException, parameter); return; } if (exception is IntranetGuiRepositoryException) { commandException = new IntranetGuiCommandException(Resource.GetExceptionMessage(ExceptionMessage.ErrorPostingAccountingLine), Resource.GetExceptionMessage(ExceptionMessage.ErrorUpdateFinansstyringRepository), this, _finansstyringRepository, exception); base.HandleException(commandException, parameter); return; } if (exception is IntranetGuiSystemException) { base.HandleException(exception, parameter); return; } systemException = new IntranetGuiSystemException(Resource.GetExceptionMessage(ExceptionMessage.CommandError, "BogføringAddCommand", exception.Message), exception); base.HandleException(systemException, parameter); } finally { if (OnError != null) { OnError.Invoke(this, new HandleExceptionEventArgs(commandException ?? systemException ?? exception)); } } }
public void TestAtConstructorInitiererIntranetGuiCommandExceptionUdenInnerException() { var fixture = new Fixture(); var message = fixture.Create <string>(); var reason = fixture.Create <string>(); var commandContext = fixture.Create <object>(); var reasonContext = fixture.Create <object>(); var intranetGuiCommandException = new IntranetGuiCommandException(message, reason, commandContext, reasonContext); Assert.That(intranetGuiCommandException, Is.Not.Null); Assert.That(intranetGuiCommandException.Message, Is.Not.Null); Assert.That(intranetGuiCommandException.Message, Is.Not.Empty); Assert.That(intranetGuiCommandException.Message, Is.EqualTo(message)); Assert.That(intranetGuiCommandException.Reason, Is.Not.Null); Assert.That(intranetGuiCommandException.Reason, Is.Not.Empty); Assert.That(intranetGuiCommandException.Reason, Is.EqualTo(reason)); Assert.That(intranetGuiCommandException.CommandContext, Is.Not.Null); Assert.That(intranetGuiCommandException.CommandContext, Is.EqualTo(commandContext)); Assert.That(intranetGuiCommandException.ReasonContext, Is.Not.Null); Assert.That(intranetGuiCommandException.ReasonContext, Is.EqualTo(reasonContext)); Assert.That(intranetGuiCommandException.InnerException, Is.Null); }