Пример #1
0
 public JsonPatchException(JsonPatchError jsonPatchError, Exception innerException, int suggestedStatusCode)
     : base(jsonPatchError.ErrorMessage, innerException)
 {
     FailedOperation     = jsonPatchError.Operation;
     AffectedObject      = jsonPatchError.AffectedObject;
     SuggestedStatusCode = suggestedStatusCode;
 }
Пример #2
0
 public JsonPatchException(JsonPatchError jsonPatchError, Exception innerException, int suggestedStatusCode)
     : base(jsonPatchError.ErrorMessage, innerException)
 {
     FailedOperation = jsonPatchError.Operation;
     AffectedObject = jsonPatchError.AffectedObject;
     SuggestedStatusCode = suggestedStatusCode;
 }
Пример #3
0
        /// <summary>
        /// Updates the model state with errors that were given by the patch operation.
        /// </summary>
        /// <param name="error">The error returned by the patch operation.</param>
        /// <param name="modelState">The model stat where validation issues can be added and tracked by property.</param>
        /// <param name="prefix">Prefix to use for the property name in the model state.</param>
        private static void ApplyErrorToModelState(JsonPatchError error, ModelStateDictionary modelState, string prefix)
        {
            var name = error.AffectedObject.GetType().Name;

            modelState.TryAddModelError
            (
                string.IsNullOrEmpty(prefix) ? name : $"{prefix}.{name}",
                $"Op: {error.Operation.OperationType}, Path: {error.Operation.path}, Value: {error.Operation.value}, Error: {error.ErrorMessage}"
            );
        }
Пример #4
0
 private void LogError(JsonPatchError jsonPatchError)
 {
     if (LogErrorAction != null)
     {
         LogErrorAction(jsonPatchError);
     }
     else
     {
         throw new JsonPatchException(jsonPatchError);
     }
 }
Пример #5
0
 public void LogErrorMessage(JsonPatchError patchError)
 {
     ErrorMessage = patchError.ErrorMessage;
 }
Пример #6
0
 public JsonPatchException(JsonPatchError jsonPatchError)
     : this(jsonPatchError, null)
 {
 }
Пример #7
0
 public JsonPatchException(JsonPatchError jsonPatchError, Exception innerException)
     : base(jsonPatchError.ErrorMessage, innerException)
 {
     FailedOperation = jsonPatchError.Operation;
     AffectedObject  = jsonPatchError.AffectedObject;
 }
Пример #8
0
 private void LogError(JsonPatchError jsonPatchError)
 {
     if (LogErrorAction != null)
     {
         LogErrorAction(jsonPatchError);
     }
     else
     {
         throw new JsonPatchException(jsonPatchError);
     }
 }
Пример #9
0
 public JsonPatchException(JsonPatchError jsonPatchError, int suggestedStatusCode)
     : this(jsonPatchError, null, suggestedStatusCode)
 {
 }
Пример #10
0
 public JsonPatchException(JsonPatchError jsonPatchError, int suggestedStatusCode)
     : this(jsonPatchError, null, suggestedStatusCode)
 {
 }
Пример #11
0
 public JsonPatchException(JsonPatchError jsonPatchError)
     : this(jsonPatchError, null)
 {
 }
Пример #12
0
 public JsonPatchException(JsonPatchError jsonPatchError, Exception innerException)
     : base(jsonPatchError.ErrorMessage, innerException)
 {
     FailedOperation = jsonPatchError.Operation;
     AffectedObject = jsonPatchError.AffectedObject;
 }
Пример #13
0
 public JsonPatchException(JsonPatchError <TModel> jsonPatchError, Exception innerException)
     : this(jsonPatchError)
 {
     InnerException = innerException;
 }
Пример #14
0
 public JsonPatchException(JsonPatchError <TModel> jsonPatchError)
 {
     FailedOperation = jsonPatchError.Operation;
     _message        = jsonPatchError.ErrorMessage;
     AffectedObject  = jsonPatchError.AffectedObject;
 }