internal DocumentTranslationError(DocumentTranslationErrorCode errorCode, string message, string target, InnerTranslationError 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; } InnerError = null; }
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)); }