From 716fa75dfd244fe67f99036230ab2755e14073a3 Mon Sep 17 00:00:00 2001 From: Mariana Rios Flores Date: Wed, 14 Jul 2021 15:47:38 -0700 Subject: [PATCH] DocumentTranslationError --- ....AI.Translation.Document.netstandard2.0.cs | 8 ++++--- .../src/DocumentTranslationError.cs | 17 +++++++++++-- .../src/DocumentTranslationOperation.cs | 2 +- .../Models/DocumentStatus.Serialization.cs | 2 +- .../DocumentTranslationError.Serialization.cs | 2 +- .../Models/DocumentTranslationError.cs | 24 +------------------ .../TranslationErrorResponse.Serialization.cs | 2 +- .../Models/TranslationErrorResponse.cs | 4 ++-- .../Models/TranslationStatus.Serialization.cs | 2 +- .../src/Generated/Models/TranslationStatus.cs | 4 ++-- 10 files changed, 30 insertions(+), 37 deletions(-) diff --git a/sdk/translation/Azure.AI.Translation.Document/api/Azure.AI.Translation.Document.netstandard2.0.cs b/sdk/translation/Azure.AI.Translation.Document/api/Azure.AI.Translation.Document.netstandard2.0.cs index d37ebc4ae4255..d3900236c68ff 100644 --- a/sdk/translation/Azure.AI.Translation.Document/api/Azure.AI.Translation.Document.netstandard2.0.cs +++ b/sdk/translation/Azure.AI.Translation.Document/api/Azure.AI.Translation.Document.netstandard2.0.cs @@ -52,9 +52,11 @@ public enum ServiceVersion V1_0 = 1, } } - public partial class DocumentTranslationError + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct DocumentTranslationError { - internal DocumentTranslationError() { } + private readonly object _dummy; + private readonly int _dummyPrimitive; public Azure.AI.Translation.Document.DocumentTranslationErrorCode ErrorCode { get { throw null; } } public string Message { get { throw null; } } public string Target { get { throw null; } } @@ -197,7 +199,7 @@ internal TranslationStatus() { } public int DocumentsNotStarted { get { throw null; } } public int DocumentsSucceeded { get { throw null; } } public int DocumentsTotal { get { throw null; } } - public Azure.AI.Translation.Document.DocumentTranslationError Error { get { throw null; } } + public Azure.AI.Translation.Document.DocumentTranslationError? Error { get { throw null; } } public string Id { get { throw null; } } public System.DateTimeOffset LastModified { get { throw null; } } public Azure.AI.Translation.Document.DocumentTranslationStatus Status { get { throw null; } } diff --git a/sdk/translation/Azure.AI.Translation.Document/src/DocumentTranslationError.cs b/sdk/translation/Azure.AI.Translation.Document/src/DocumentTranslationError.cs index 6eb16a75538d7..9367af55d0870 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/DocumentTranslationError.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/DocumentTranslationError.cs @@ -10,7 +10,7 @@ namespace Azure.AI.Translation.Document /// Represents an error that occurred during a translation operation. /// [CodeGenModel("TranslationError")] - public partial class DocumentTranslationError + public readonly partial struct DocumentTranslationError { /// /// Error code that serves as an indicator of the HTTP error code. @@ -18,7 +18,18 @@ public partial class DocumentTranslationError [CodeGenMember("Code")] public DocumentTranslationErrorCode ErrorCode { get; } - internal InnerTranslationError InnerError { get; } + /// + /// Message that contains more information about the reason of the error. + /// + public string Message { get; } + + /// + /// Gets the source of the error. + /// For example it would be 'documents' or 'document id' in case of invalid document. + /// + public string Target { get; } + + internal readonly InnerTranslationError InnerError { get; } internal DocumentTranslationError(DocumentTranslationErrorCode errorCode, string message, string target, InnerTranslationError innerError) { @@ -35,6 +46,8 @@ internal DocumentTranslationError(DocumentTranslationErrorCode errorCode, string Message = message; Target = target; } + + InnerError = null; } } } diff --git a/sdk/translation/Azure.AI.Translation.Document/src/DocumentTranslationOperation.cs b/sdk/translation/Azure.AI.Translation.Document/src/DocumentTranslationOperation.cs index 7f4b71eb2eab7..92ad595f912b1 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/DocumentTranslationOperation.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/DocumentTranslationOperation.cs @@ -299,7 +299,7 @@ private async ValueTask UpdateStatusAsync(bool async, CancellationToke } else if (update.Value.Status == DocumentTranslationStatus.ValidationFailed) { - DocumentTranslationError error = update.Value.Error; + DocumentTranslationError error = (DocumentTranslationError)update.Value.Error; _requestFailedException = _diagnostics.CreateRequestFailedException(_response, error.Message, error.ErrorCode.ToString(), CreateAdditionalInformation(error)); _hasCompleted = true; throw _requestFailedException; diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/DocumentStatus.Serialization.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/DocumentStatus.Serialization.cs index 832ccee5d4682..45ddc0ac40464 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/DocumentStatus.Serialization.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/DocumentStatus.Serialization.cs @@ -93,7 +93,7 @@ internal static DocumentStatus DeserializeDocumentStatus(JsonElement element) continue; } } - return new DocumentStatus(path.Value, sourcePath, createdDateTimeUtc, lastActionDateTimeUtc, status, to, error.Value, progress, id, characterCharged); + return new DocumentStatus(path.Value, sourcePath, createdDateTimeUtc, lastActionDateTimeUtc, status, to, error, progress, id, characterCharged); } } } diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/DocumentTranslationError.Serialization.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/DocumentTranslationError.Serialization.cs index 76f332a32f739..d4ccfd36f17c9 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/DocumentTranslationError.Serialization.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/DocumentTranslationError.Serialization.cs @@ -11,7 +11,7 @@ namespace Azure.AI.Translation.Document { - public partial class DocumentTranslationError + public partial struct DocumentTranslationError { internal static DocumentTranslationError DeserializeDocumentTranslationError(JsonElement element) { diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/DocumentTranslationError.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/DocumentTranslationError.cs index aa62bb63b0dd1..95b328ab9946c 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/DocumentTranslationError.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/DocumentTranslationError.cs @@ -11,29 +11,7 @@ namespace Azure.AI.Translation.Document { /// This contains an outer error with error code, message, details, target and an inner error with more descriptive details. - public partial class DocumentTranslationError + public readonly partial struct DocumentTranslationError { - /// Initializes a new instance of DocumentTranslationError. - /// Enums containing high level error codes. - /// Gets high level error message. - /// is null. - internal DocumentTranslationError(DocumentTranslationErrorCode errorCode, string message) - { - if (message == null) - { - throw new ArgumentNullException(nameof(message)); - } - - ErrorCode = errorCode; - Message = message; - } - /// Gets high level error message. - public string Message { get; } - /// - /// Gets the source of the error. - /// - /// For example it would be "documents" or "document id" in case of invalid document. - /// - public string Target { get; } } } diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/TranslationErrorResponse.Serialization.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/TranslationErrorResponse.Serialization.cs index 216633ee145d9..05907280c82a2 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/TranslationErrorResponse.Serialization.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/TranslationErrorResponse.Serialization.cs @@ -29,7 +29,7 @@ internal static TranslationErrorResponse DeserializeTranslationErrorResponse(Jso continue; } } - return new TranslationErrorResponse(error.Value); + return new TranslationErrorResponse(Optional.ToNullable(error)); } } } diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/TranslationErrorResponse.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/TranslationErrorResponse.cs index e04e1783e56af..2c7d4b7618b29 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/TranslationErrorResponse.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/TranslationErrorResponse.cs @@ -25,12 +25,12 @@ internal TranslationErrorResponse() /// Initializes a new instance of TranslationErrorResponse. /// This contains an outer error with error code, message, details, target and an inner error with more descriptive details. - internal TranslationErrorResponse(DocumentTranslationError error) + internal TranslationErrorResponse(DocumentTranslationError? error) { Error = error; } /// This contains an outer error with error code, message, details, target and an inner error with more descriptive details. - public DocumentTranslationError Error { get; } + public DocumentTranslationError? Error { get; } } } diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/TranslationStatus.Serialization.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/TranslationStatus.Serialization.cs index c7489e5cfbf50..b1da8cdb55574 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/TranslationStatus.Serialization.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/TranslationStatus.Serialization.cs @@ -60,7 +60,7 @@ internal static TranslationStatus DeserializeTranslationStatus(JsonElement eleme continue; } } - return new TranslationStatus(id, createdDateTimeUtc, lastActionDateTimeUtc, status, error.Value, summary); + return new TranslationStatus(id, createdDateTimeUtc, lastActionDateTimeUtc, status, Optional.ToNullable(error), summary); } } } diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/TranslationStatus.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/TranslationStatus.cs index 73efaf5929d6a..5b0af04a441ea 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/TranslationStatus.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/TranslationStatus.cs @@ -45,7 +45,7 @@ internal TranslationStatus(string id, DateTimeOffset createdOn, DateTimeOffset l /// List of possible statuses for job or document. /// This contains an outer error with error code, message, details, target and an inner error with more descriptive details. /// . - internal TranslationStatus(string id, DateTimeOffset createdOn, DateTimeOffset lastModified, DocumentTranslationStatus status, DocumentTranslationError error, StatusSummary summary) + internal TranslationStatus(string id, DateTimeOffset createdOn, DateTimeOffset lastModified, DocumentTranslationStatus status, DocumentTranslationError? error, StatusSummary summary) { Id = id; CreatedOn = createdOn; @@ -57,6 +57,6 @@ internal TranslationStatus(string id, DateTimeOffset createdOn, DateTimeOffset l /// List of possible statuses for job or document. public DocumentTranslationStatus Status { get; } /// This contains an outer error with error code, message, details, target and an inner error with more descriptive details. - public DocumentTranslationError Error { get; } + public DocumentTranslationError? Error { get; } } }