Skip to content

Commit 6a67b14

Browse files
authored
DocumentTranslationError (Azure#22749)
1 parent c324680 commit 6a67b14

10 files changed

+30
-37
lines changed

sdk/translation/Azure.AI.Translation.Document/api/Azure.AI.Translation.Document.netstandard2.0.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ public enum ServiceVersion
5252
V1_0 = 1,
5353
}
5454
}
55-
public partial class DocumentTranslationError
55+
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
56+
public readonly partial struct DocumentTranslationError
5657
{
57-
internal DocumentTranslationError() { }
58+
private readonly object _dummy;
59+
private readonly int _dummyPrimitive;
5860
public Azure.AI.Translation.Document.DocumentTranslationErrorCode ErrorCode { get { throw null; } }
5961
public string Message { get { throw null; } }
6062
public string Target { get { throw null; } }
@@ -184,7 +186,7 @@ internal TranslationStatus() { }
184186
public int DocumentsNotStarted { get { throw null; } }
185187
public int DocumentsSucceeded { get { throw null; } }
186188
public int DocumentsTotal { get { throw null; } }
187-
public Azure.AI.Translation.Document.DocumentTranslationError Error { get { throw null; } }
189+
public Azure.AI.Translation.Document.DocumentTranslationError? Error { get { throw null; } }
188190
public string Id { get { throw null; } }
189191
public System.DateTimeOffset LastModified { get { throw null; } }
190192
public Azure.AI.Translation.Document.DocumentTranslationStatus Status { get { throw null; } }

sdk/translation/Azure.AI.Translation.Document/src/DocumentTranslationError.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,26 @@ namespace Azure.AI.Translation.Document
1010
/// Represents an error that occurred during a translation operation.
1111
/// </summary>
1212
[CodeGenModel("TranslationError")]
13-
public partial class DocumentTranslationError
13+
public readonly partial struct DocumentTranslationError
1414
{
1515
/// <summary>
1616
/// Error code that serves as an indicator of the HTTP error code.
1717
/// </summary>
1818
[CodeGenMember("Code")]
1919
public DocumentTranslationErrorCode ErrorCode { get; }
2020

21-
internal InnerTranslationError InnerError { get; }
21+
/// <summary>
22+
/// Message that contains more information about the reason of the error.
23+
/// </summary>
24+
public string Message { get; }
25+
26+
/// <summary>
27+
/// Gets the source of the error.
28+
/// For example it would be 'documents' or 'document id' in case of invalid document.
29+
/// </summary>
30+
public string Target { get; }
31+
32+
internal readonly InnerTranslationError InnerError { get; }
2233

2334
internal DocumentTranslationError(DocumentTranslationErrorCode errorCode, string message, string target, InnerTranslationError innerError)
2435
{
@@ -35,6 +46,8 @@ internal DocumentTranslationError(DocumentTranslationErrorCode errorCode, string
3546
Message = message;
3647
Target = target;
3748
}
49+
50+
InnerError = null;
3851
}
3952
}
4053
}

sdk/translation/Azure.AI.Translation.Document/src/DocumentTranslationOperation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ private async ValueTask<Response> UpdateStatusAsync(bool async, CancellationToke
299299
}
300300
else if (update.Value.Status == DocumentTranslationStatus.ValidationFailed)
301301
{
302-
DocumentTranslationError error = update.Value.Error;
302+
DocumentTranslationError error = (DocumentTranslationError)update.Value.Error;
303303
_requestFailedException = _diagnostics.CreateRequestFailedException(_response, error.Message, error.ErrorCode.ToString(), CreateAdditionalInformation(error));
304304
_hasCompleted = true;
305305
throw _requestFailedException;

sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/DocumentStatus.Serialization.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/DocumentTranslationError.Serialization.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/DocumentTranslationError.cs

Lines changed: 1 addition & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/TranslationErrorResponse.Serialization.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/TranslationErrorResponse.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/TranslationStatus.Serialization.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/translation/Azure.AI.Translation.Document/src/Generated/Models/TranslationStatus.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)