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

[LLC] Create RequestFailedException from Response #24283

Merged
merged 15 commits into from
Oct 1, 2021

Conversation

annelo-msft
Copy link
Member

@annelo-msft annelo-msft commented Sep 28, 2021

Add the ability to create a new RequestFailedException from response to Azure.Core.Experimental:

Our overarching goal (per #23372) is to implement this API:

        public static implicit operator Pet(Response response)
        {
            if (response.IsError)
            {
                throw new RequestFailedException(response);
            }

            return DeserializePet(JsonDocument.Parse(response.Content.ToMemory()));

However, at the moment, we will keep this work in Experimental, which means it will need to be modified as follows:

        public static implicit operator Pet(Response response)
        {
            if (response.IsError())
            {
                throw response.CreateRequestFailedException();
            }

            return DeserializePet(JsonDocument.Parse(response.Content.ToMemory()));
        }

This PR adds the CreateRequestFailedException() method to Response.

Addresses: #23372

@ghost ghost added the Azure.Core label Sep 28, 2021
@annelo-msft annelo-msft marked this pull request as draft September 28, 2021 21:41
@azure-sdk
Copy link
Collaborator

API changes have been detected in this PR. You can review API changes here

API changes

+         public static RequestFailedException CreateRequestFailedException(this Response response);

@azure-sdk
Copy link
Collaborator

API changes have been detected in this PR. You can review API changes here

API changes

+         public static RequestFailedException CreateRequestFailedException(this Response response);

@annelo-msft annelo-msft marked this pull request as ready for review October 1, 2021 00:31
@annelo-msft annelo-msft enabled auto-merge (squash) October 1, 2021 00:31
@annelo-msft annelo-msft merged commit 2a91880 into Azure:main Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants