[BUG] Core: When operation failed, need a better way to surface additional info
See original GitHub issueLibrary name and version
Azure.AI.Translation.Document 1.0.0
Describe the bug
When you get failed request exception, ex.Message gives you something that requires additional parsing https://github.com/Azure/azure-sdk-for-net/blob/c3339441dc852529ac6647251bef9fc0dd5cef2d/sdk/translation/Azure.AI.Translation.Document/src/DocumentTranslationOperation.cs#L230
Here is what ex.Message returns as a string
Cannot access source document location with the current permissions.
Status: 200 (OK)
ErrorCode: InvalidRequest
Additional Information:
AdditionalInformation: InvalidRequest: Cannot access source document location with the current permissions.
Target: Operation
Raw:
{"code":"InvalidRequest","message":"Cannot access source document location with the current permissions.","target":"Operation","innerError":{"code":"InvalidDocumentAccessLevel","message":"Cannot access source document location with the current permissions."}}
Content:
Headers:
Date: Tue, 06 Sep 2022 21:20:35 GMT
Server: Kestrel
Cache-Control: public, max-age=1
ETag: "A03DB87237F7C4A92D0B0F8A2E799E345C8A27A1E652D54D0B7653EF9D36E4B3"
Retry-After: 1
Transfer-Encoding: chunked
X-RequestId: 0HMKG9LI745IU:00000008
Content-Type: application/json; charset=utf-8
The user can get operation.status to get “InvalidRequest”, but there is no systematic way to get the actual message - “Cannot access source document …” or the inner error code “InvalidDocumentAccessLevel”.
Expected behavior
some way to access the message or inner error code. Maybe through the operation object? or through the exception object?
Actual behavior
exception is thrown but hard for user to parse
Reproduction Steps
submit a request to a path without access token or permission.
Environment
No response
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
This behavior is intentional. The thought process here is that any code written against other details isn’t safe. https://github.com/Azure/azure-sdk-for-net/issues/25384#issuecomment-972597959 this has a good explanation on why we chose to do it.
Closing, per @pallavit’s comment.