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 <InnerErrorV2> 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 = InnerErrorV2.DeserializeInnerErrorV2(property.Value); continue; } } return(new DocumentTranslationError(code, message, target.Value, innerError.Value)); }