Skip to content

Commit

Permalink
Reverting the use of Azure.core.Foundation.Error object
Browse files Browse the repository at this point in the history
  • Loading branch information
hamshavathimunibyraiah committed Nov 7, 2024
1 parent 6d2bfd4 commit 7523022
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ interface SingleDocumentTranslationClient {

@@clientName(DocumentTranslation.TargetInput, "TranslationTarget", "python");

@@clientName(DocumentTranslation.TranslationStatus.error,
@@clientName(DocumentTranslation.TranslationError,
"DocumentTranslationError",
"python"
);
Expand Down
95 changes: 92 additions & 3 deletions specification/translation/Azure.AI.DocumentTranslation/models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ using TypeSpec.Rest;
using TypeSpec.Http;
using Azure.Core;
using TypeSpec.Versioning;
using Azure.Core.Foundations;

namespace DocumentTranslation;
@doc("Document Translate Request Content")
Expand Down Expand Up @@ -70,6 +69,32 @@ union StorageInputType {
string,
}

@doc("Enums containing high level error codes.")
union TranslationErrorCode {
@doc("InvalidRequest")
InvalidRequest: "InvalidRequest",

@doc("InvalidArgument")
InvalidArgument: "InvalidArgument",

@doc("InternalServerError")
InternalServerError: "InternalServerError",

@doc("ServiceUnavailable")
ServiceUnavailable: "ServiceUnavailable",

@doc("ResourceNotFound")
ResourceNotFound: "ResourceNotFound",

@doc("Unauthorized")
Unauthorized: "Unauthorized",

@doc("RequestRateTooHigh")
RequestRateTooHigh: "RequestRateTooHigh",

string,
}

@doc("List of possible statuses for job or document")
union Status {
@doc("NotStarted")
Expand Down Expand Up @@ -222,12 +247,76 @@ model TranslationStatus {
This contains an outer error with error code, message, details, target and an
inner error with more descriptive details.
""")
error?: Error;
error?: TranslationError;

@doc("Status Summary")
summary: StatusSummary;
}

@doc("""
This contains an outer error with error code, message, details, target and an
inner error with more descriptive details.
""")
model TranslationError {
@doc("Enums containing high level error codes.")
code: TranslationErrorCode;

@doc("Gets high level error message.")
message: string;

@doc("""
Gets the source of the error.
For example it would be \"documents\" or
\"document id\" in case of invalid document.
""")
@visibility("read")
target?: string;

@doc("""
New Inner Error format which conforms to Cognitive Services API Guidelines
which is available at
https://microsoft.sharepoint.com/%3Aw%3A/t/CognitiveServicesPMO/EUoytcrjuJdKpeOKIK_QRC8BPtUYQpKBi8JsWyeDMRsWlQ?e=CPq8ow.
This
contains required properties ErrorCode, message and optional properties target,
details(key value pair), inner error(this can be nested).
""")
innerError?: InnerTranslationError;
}

@doc("""
New Inner Error format which conforms to Cognitive Services API Guidelines
which is available at
https://microsoft.sharepoint.com/%3Aw%3A/t/CognitiveServicesPMO/EUoytcrjuJdKpeOKIK_QRC8BPtUYQpKBi8JsWyeDMRsWlQ?e=CPq8ow.
This
contains required properties ErrorCode, message and optional properties target,
details(key value pair), inner error(this can be nested).
""")
model InnerTranslationError {
@doc("Gets code error string.")
code: string;

@doc("Gets high level error message.")
message: string;

@doc("""
Gets the source of the error.
For example it would be \"documents\" or
\"document id\" in case of invalid document.
""")
@visibility("read")
target?: string;

@doc("""
New Inner Error format which conforms to Cognitive Services API Guidelines
which is available at
https://microsoft.sharepoint.com/%3Aw%3A/t/CognitiveServicesPMO/EUoytcrjuJdKpeOKIK_QRC8BPtUYQpKBi8JsWyeDMRsWlQ?e=CPq8ow.
This
contains required properties ErrorCode, message and optional properties target,
details(key value pair), inner error(this can be nested).
""")
innerError?: InnerTranslationError;
}

@doc("Status Summary")
model StatusSummary {
@doc("Total count")
Expand Down Expand Up @@ -278,7 +367,7 @@ model DocumentStatus {
This contains an outer error with error code, message, details, target and an
inner error with more descriptive details.
""")
error?: Error;
error?: TranslationError;

@doc("Progress of the translation if available")
@maxValue(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@
"description": "To language"
},
"error": {
"$ref": "#/definitions/Azure.Core.Foundations.Error",
"$ref": "#/definitions/TranslationError",
"description": "This contains an outer error with error code, message, details, target and an\ninner error with more descriptive details."
},
"progress": {
Expand Down Expand Up @@ -991,6 +991,33 @@
"format"
]
},
"InnerTranslationError": {
"type": "object",
"description": "New Inner Error format which conforms to Cognitive Services API Guidelines\nwhich is available at\nhttps://microsoft.sharepoint.com/%3Aw%3A/t/CognitiveServicesPMO/EUoytcrjuJdKpeOKIK_QRC8BPtUYQpKBi8JsWyeDMRsWlQ?e=CPq8ow.\nThis\ncontains required properties ErrorCode, message and optional properties target,\ndetails(key value pair), inner error(this can be nested).",
"properties": {
"code": {
"type": "string",
"description": "Gets code error string."
},
"message": {
"type": "string",
"description": "Gets high level error message."
},
"target": {
"type": "string",
"description": "Gets the source of the error. \nFor example it would be \"documents\" or\n\"document id\" in case of invalid document.",
"readOnly": true
},
"innerError": {
"$ref": "#/definitions/InnerTranslationError",
"description": "New Inner Error format which conforms to Cognitive Services API Guidelines\nwhich is available at\nhttps://microsoft.sharepoint.com/%3Aw%3A/t/CognitiveServicesPMO/EUoytcrjuJdKpeOKIK_QRC8BPtUYQpKBi8JsWyeDMRsWlQ?e=CPq8ow.\nThis\ncontains required properties ErrorCode, message and optional properties target,\ndetails(key value pair), inner error(this can be nested)."
}
},
"required": [
"code",
"message"
]
},
"SourceInput": {
"type": "object",
"description": "Source of the input documents",
Expand Down Expand Up @@ -1230,6 +1257,87 @@
"language"
]
},
"TranslationError": {
"type": "object",
"description": "This contains an outer error with error code, message, details, target and an\ninner error with more descriptive details.",
"properties": {
"code": {
"$ref": "#/definitions/TranslationErrorCode",
"description": "Enums containing high level error codes."
},
"message": {
"type": "string",
"description": "Gets high level error message."
},
"target": {
"type": "string",
"description": "Gets the source of the error. \nFor example it would be \"documents\" or\n\"document id\" in case of invalid document.",
"readOnly": true
},
"innerError": {
"$ref": "#/definitions/InnerTranslationError",
"description": "New Inner Error format which conforms to Cognitive Services API Guidelines\nwhich is available at\nhttps://microsoft.sharepoint.com/%3Aw%3A/t/CognitiveServicesPMO/EUoytcrjuJdKpeOKIK_QRC8BPtUYQpKBi8JsWyeDMRsWlQ?e=CPq8ow.\nThis\ncontains required properties ErrorCode, message and optional properties target,\ndetails(key value pair), inner error(this can be nested)."
}
},
"required": [
"code",
"message"
]
},
"TranslationErrorCode": {
"type": "string",
"description": "Enums containing high level error codes.",
"enum": [
"InvalidRequest",
"InvalidArgument",
"InternalServerError",
"ServiceUnavailable",
"ResourceNotFound",
"Unauthorized",
"RequestRateTooHigh"
],
"x-ms-enum": {
"name": "TranslationErrorCode",
"modelAsString": true,
"values": [
{
"name": "InvalidRequest",
"value": "InvalidRequest",
"description": "InvalidRequest"
},
{
"name": "InvalidArgument",
"value": "InvalidArgument",
"description": "InvalidArgument"
},
{
"name": "InternalServerError",
"value": "InternalServerError",
"description": "InternalServerError"
},
{
"name": "ServiceUnavailable",
"value": "ServiceUnavailable",
"description": "ServiceUnavailable"
},
{
"name": "ResourceNotFound",
"value": "ResourceNotFound",
"description": "ResourceNotFound"
},
{
"name": "Unauthorized",
"value": "Unauthorized",
"description": "Unauthorized"
},
{
"name": "RequestRateTooHigh",
"value": "RequestRateTooHigh",
"description": "RequestRateTooHigh"
}
]
}
},
"TranslationStatus": {
"type": "object",
"description": "Translation job status response",
Expand All @@ -1253,7 +1361,7 @@
"description": "List of possible statuses for job or document"
},
"error": {
"$ref": "#/definitions/Azure.Core.Foundations.Error",
"$ref": "#/definitions/TranslationError",
"description": "This contains an outer error with error code, message, details, target and an\ninner error with more descriptive details."
},
"summary": {
Expand Down

0 comments on commit 7523022

Please sign in to comment.