Skip to content

Commit

Permalink
DocumentTranslationError (Azure#22749)
Browse files Browse the repository at this point in the history
  • Loading branch information
maririos authored Jul 21, 2021
1 parent c324680 commit 6a67b14
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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; } }
Expand Down Expand Up @@ -184,7 +186,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; } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,26 @@ namespace Azure.AI.Translation.Document
/// Represents an error that occurred during a translation operation.
/// </summary>
[CodeGenModel("TranslationError")]
public partial class DocumentTranslationError
public readonly partial struct DocumentTranslationError
{
/// <summary>
/// Error code that serves as an indicator of the HTTP error code.
/// </summary>
[CodeGenMember("Code")]
public DocumentTranslationErrorCode ErrorCode { get; }

internal InnerTranslationError InnerError { get; }
/// <summary>
/// Message that contains more information about the reason of the error.
/// </summary>
public string Message { get; }

/// <summary>
/// Gets the source of the error.
/// For example it would be 'documents' or 'document id' in case of invalid document.
/// </summary>
public string Target { get; }

internal readonly InnerTranslationError InnerError { get; }

internal DocumentTranslationError(DocumentTranslationErrorCode errorCode, string message, string target, InnerTranslationError innerError)
{
Expand All @@ -35,6 +46,8 @@ internal DocumentTranslationError(DocumentTranslationErrorCode errorCode, string
Message = message;
Target = target;
}

InnerError = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ private async ValueTask<Response> 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;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6a67b14

Please sign in to comment.