public void WHEN_one_composer_exception_with_errors_SHOULD_not_set_context_response() { // Arrange AggregatedComposerExceptionFilter filter = _container.CreateInstance <AggregatedComposerExceptionFilter>(); var innerException = new ComposerException(new List <ErrorViewModel> { new ErrorViewModel { ErrorCode = GetRandom.String(1), ErrorMessage = GetRandom.String(1) }, new ErrorViewModel { ErrorCode = GetRandom.String(1), ErrorMessage = GetRandom.String(1) } }); var context = new HttpActionExecutedContext { Exception = new AggregateException(innerException), ActionContext = new HttpActionContext() // required or setting the context response will throw exception... }; // Act filter.OnException(context); // Assert context.Response.Should().NotBeNull(); }
private void ClearEditModeIfCartDraftDoesNotExist(string cartType, ComposerException ex) { if (ex.Errors?.FirstOrDefault(e => e.ErrorCode == "CartDoesNotExist") != null && cartType == CartConfiguration.OrderDraftCartType && EditingOrderProvider.IsEditMode()) { EditingOrderProvider.ClearEditMode(); } }
private AggregateException GetAggregateExceptionWithComposerExceptionsOnly() { var innerException = new ComposerException(new List <ErrorViewModel> { new ErrorViewModel { ErrorCode = GetRandom.String(1), ErrorMessage = GetRandom.String(1) } }); return(new AggregateException(innerException)); }
private AggregateException GetAggregateExceptionWithMixExceptions() { var innerException1 = new ComposerException(new List <ErrorViewModel> { new ErrorViewModel { ErrorCode = GetRandom.String(1), ErrorMessage = GetRandom.String(1) } }); var innerException2 = new InvalidOperationException(); return(new AggregateException(innerException1, innerException2)); }
private void HandleException(Exception e, object request) { if (e is ValidationError vError) { Log.ErrorException($"{GetRequestErrorDescription(request)} ErrorCode: {vError.ErrorCode}, ErrorMessage: {vError.ErrorMessage}", vError); ComposerException.Create(vError).ThrowIfAnyError(); } else if (e is WebServiceException wsException) { Log.ErrorException($"{GetRequestErrorDescription(request)} ErrorCode: {wsException.ErrorCode}, ErrorMessage: {wsException.ErrorMessage}", wsException); ComposerException.Create(wsException).ThrowIfAnyError(); } else if (e is WebException webException) { Log.ErrorException($"{GetRequestErrorDescription(request)} {e.Message}", e); ComposerException.Create(webException).ThrowIfAnyError(); } }