private static ErrorInfo CreateDetailedErrorInfoFromException(Exception exception) { var detailBuilder = new StringBuilder(); AddExceptionToDetails(exception, detailBuilder); var errorInfo = new ErrorInfo(exception.Message, detailBuilder.ToString()); if (exception is OwValidationException) { errorInfo.ValidationErrors = GetValidationErrorInfos(exception as OwValidationException); } return errorInfo; }
public static MvcAjaxResponse ToMvcAjaxResponse(ModelStateDictionary modelState) { if (modelState.IsValid) { return new MvcAjaxResponse(); } var validationErrors = new List<ValidationErrorInfo>(); foreach (var state in modelState) { foreach (var error in state.Value.Errors) { validationErrors.Add(new ValidationErrorInfo(error.ErrorMessage, state.Key)); } } var errorInfo = new ErrorInfo(OwWebLocalizedMessages.ValidationError) { ValidationErrors = validationErrors.ToArray() }; return new MvcAjaxResponse(errorInfo); }
/// <summary> /// Creates a new <see cref="OwException"/> object. /// </summary> /// <param name="errorInfo">Exception message</param> public OwRemoteCallException(ErrorInfo errorInfo) : base(errorInfo.Message) { ErrorInfo = errorInfo; }