/// <summary> /// Initializes a new instance of <see cref="Document.DocumentTranslationError"/> for mocking purposes. /// </summary> /// <param name="errorCode">Sets the <see cref="DocumentTranslationError.ErrorCode"/> property.</param> /// <param name="message">Sets the <see cref="DocumentTranslationError.Message"/> property.</param> /// <param name="target">Sets the <see cref="DocumentTranslationError.Target"/> property.</param> /// <returns>A new instance of <see cref="Document.DocumentTranslationError"/> for mocking purposes.</returns> public static DocumentTranslationError DocumentTranslationError( DocumentTranslationErrorCode errorCode, string message, string target ) { return(new DocumentTranslationError(errorCode, message, target, default)); }
internal DocumentTranslationError(DocumentTranslationErrorCode errorCode, string message) { if (message == null) { throw new ArgumentNullException(nameof(message)); } ErrorCode = errorCode; Message = message; }
internal DocumentTranslationError(DocumentTranslationErrorCode errorCode, string message, string target, InnerErrorV2 innerError) { if (innerError != null) { // Assigns the inner error, which should be only one level down. ErrorCode = innerError.Code; Message = innerError.Message; Target = innerError.Target; } else { ErrorCode = errorCode; Message = message; Target = target; } }
internal static DocumentTranslationError DeserializeDocumentTranslationError(JsonElement element) { DocumentTranslationErrorCode code = default; string message = default; Optional <string> target = default; Optional <InnerTranslationError> innerError = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("code")) { code = new DocumentTranslationErrorCode(property.Value.GetString()); continue; } if (property.NameEquals("message")) { message = property.Value.GetString(); continue; } if (property.NameEquals("target")) { target = property.Value.GetString(); continue; } if (property.NameEquals("innerError")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } innerError = InnerTranslationError.DeserializeInnerTranslationError(property.Value); continue; } } return(new DocumentTranslationError(code, message, target.Value, innerError.Value)); }