Description
In Azure Core, RequestFailedException
will not include the response content or headers in the message when the IsError
property of the response is false
.
We received a request in Language-Dotnet
channel, they want to see the error message from RequestFailedException
https://teams.microsoft.com/l/message/19:[email protected]/1734990642330?tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47&groupId=3e17dcb0-4257-4a30-b843-77f47f1d4121&parentMessageId=1734990642330&teamName=Azure%20SDK&channelName=Language%20-%20DotNet&createdTime=1734990642330
Current solution:
we will ask customer to write customized RequestFailedDetailsParser
and set it to Pipeline
(customize the client constructor and re-build the pipeline with the customized RequestFailedDetailsParser
).
Several DPG SDKs have adopt this solution.
Problem:
This is mgmt-plane SDK which use ArmClient
which cannot be customized to accept RequestFailedDetailsParser
.
And write customized code is heavy for customer.
Possible solution option:
And since more than one service required to retrieve the content of RequestFailedException
, Azure.Core may be can provide an API to construct the Pipeline with cutsomized parser (just like pipeline policy) when create client just like pipeline policy
There will be an optional field RequestFailedDetailsParser? RequestFailedDetailsParser
in ClientOptions
. When build pipeline, it will set the requestFailedDetailsParser
to pipeline.
public abstract class ClientOptions
{
...
public RequestFailedDetailsParser ? RequestFailedDetailsParser { get; set; }
...
}
When customer want to retrieve content from RequestFailedException
, they can write their own RequestFailedDetailsParser
and set to ClientOptions
when create client.