Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Translation] Make DocumentTranslationError a struct #22749

Merged
merged 1 commit into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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; } }
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;
kinelski marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
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;
kinelski marked this conversation as resolved.
Show resolved Hide resolved
_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.