From 7bb4164e043ec54531d0ba4e80db5c1105143eef Mon Sep 17 00:00:00 2001
From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Date: Thu, 20 Apr 2023 22:40:10 -0700
Subject: [PATCH 01/16] Add Response property to RequestFailedException
---
sdk/core/Azure.Core/api/Azure.Core.net461.cs | 1 +
sdk/core/Azure.Core/api/Azure.Core.net5.0.cs | 1 +
sdk/core/Azure.Core/api/Azure.Core.net6.0.cs | 1 +
.../api/Azure.Core.netcoreapp2.1.cs | 1 +
.../api/Azure.Core.netstandard2.0.cs | 1 +
.../Azure.Core/src/RequestFailedException.cs | 51 ++++++++--------
.../tests/FailedResponseExceptionTests.cs | 59 +++++++++++++++++--
7 files changed, 83 insertions(+), 32 deletions(-)
diff --git a/sdk/core/Azure.Core/api/Azure.Core.net461.cs b/sdk/core/Azure.Core/api/Azure.Core.net461.cs
index 4ccc966869bb5..54606f45ad53e 100644
--- a/sdk/core/Azure.Core/api/Azure.Core.net461.cs
+++ b/sdk/core/Azure.Core/api/Azure.Core.net461.cs
@@ -223,6 +223,7 @@ protected RequestFailedException(System.Runtime.Serialization.SerializationInfo
public RequestFailedException(string message) { }
public RequestFailedException(string message, System.Exception? innerException) { }
public string? ErrorCode { get { throw null; } }
+ public Azure.Response? Response { get { throw null; } }
public int Status { get { throw null; } }
public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
}
diff --git a/sdk/core/Azure.Core/api/Azure.Core.net5.0.cs b/sdk/core/Azure.Core/api/Azure.Core.net5.0.cs
index 0d35cd47af870..710ef33d893da 100644
--- a/sdk/core/Azure.Core/api/Azure.Core.net5.0.cs
+++ b/sdk/core/Azure.Core/api/Azure.Core.net5.0.cs
@@ -223,6 +223,7 @@ protected RequestFailedException(System.Runtime.Serialization.SerializationInfo
public RequestFailedException(string message) { }
public RequestFailedException(string message, System.Exception? innerException) { }
public string? ErrorCode { get { throw null; } }
+ public Azure.Response? Response { get { throw null; } }
public int Status { get { throw null; } }
public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
}
diff --git a/sdk/core/Azure.Core/api/Azure.Core.net6.0.cs b/sdk/core/Azure.Core/api/Azure.Core.net6.0.cs
index 0d35cd47af870..710ef33d893da 100644
--- a/sdk/core/Azure.Core/api/Azure.Core.net6.0.cs
+++ b/sdk/core/Azure.Core/api/Azure.Core.net6.0.cs
@@ -223,6 +223,7 @@ protected RequestFailedException(System.Runtime.Serialization.SerializationInfo
public RequestFailedException(string message) { }
public RequestFailedException(string message, System.Exception? innerException) { }
public string? ErrorCode { get { throw null; } }
+ public Azure.Response? Response { get { throw null; } }
public int Status { get { throw null; } }
public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
}
diff --git a/sdk/core/Azure.Core/api/Azure.Core.netcoreapp2.1.cs b/sdk/core/Azure.Core/api/Azure.Core.netcoreapp2.1.cs
index 4ccc966869bb5..54606f45ad53e 100644
--- a/sdk/core/Azure.Core/api/Azure.Core.netcoreapp2.1.cs
+++ b/sdk/core/Azure.Core/api/Azure.Core.netcoreapp2.1.cs
@@ -223,6 +223,7 @@ protected RequestFailedException(System.Runtime.Serialization.SerializationInfo
public RequestFailedException(string message) { }
public RequestFailedException(string message, System.Exception? innerException) { }
public string? ErrorCode { get { throw null; } }
+ public Azure.Response? Response { get { throw null; } }
public int Status { get { throw null; } }
public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
}
diff --git a/sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs b/sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs
index 4ccc966869bb5..54606f45ad53e 100644
--- a/sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs
+++ b/sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs
@@ -223,6 +223,7 @@ protected RequestFailedException(System.Runtime.Serialization.SerializationInfo
public RequestFailedException(string message) { }
public RequestFailedException(string message, System.Exception? innerException) { }
public string? ErrorCode { get { throw null; } }
+ public Azure.Response? Response { get { throw null; } }
public int Status { get { throw null; } }
public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
}
diff --git a/sdk/core/Azure.Core/src/RequestFailedException.cs b/sdk/core/Azure.Core/src/RequestFailedException.cs
index fcbf1f24ce793..0a81bf8803632 100644
--- a/sdk/core/Azure.Core/src/RequestFailedException.cs
+++ b/sdk/core/Azure.Core/src/RequestFailedException.cs
@@ -31,6 +31,11 @@ public class RequestFailedException : Exception, ISerializable
///
public string? ErrorCode { get; }
+ ///
+ /// Gets the response, if any, that led to the exception.
+ ///
+ public Response? Response { get; }
+
/// Initializes a new instance of the class with a specified error message.
/// The message that describes the error.
public RequestFailedException(string message) : this(0, message)
@@ -105,6 +110,7 @@ public RequestFailedException(Response response)
public RequestFailedException(Response response, Exception? innerException)
: this(response.Status, GetRequestFailedExceptionContent(response), innerException)
{
+ Response = response;
}
///
@@ -128,6 +134,8 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont
internal static (string FormattedError, string? ErrorCode, IDictionary? Data) GetRequestFailedExceptionContent(Response response)
{
+ BufferResponseIfNeeded(response);
+
bool parseSuccess = response.RequestFailedDetailsParser == null ? TryExtractErrorContent(response, out ResponseError? error, out IDictionary? data) : response.RequestFailedDetailsParser.TryParse(response, out error, out data);
StringBuilder messageBuilder = new();
@@ -191,25 +199,23 @@ internal static (string FormattedError, string? ErrorCode, IDictionary
- /// This is intentionally sync-only as it will only be called by the ctor.
- ///
- ///
- ///
- internal static string? ReadContent(Response response)
+ private static void BufferResponseIfNeeded(Response response)
{
- string? content = null;
-
- if (response.ContentStream != null &&
- ContentTypeUtilities.TryGetTextEncoding(response.Headers.ContentType, out var encoding))
+ // Buffer into a memory stream if not already buffered
+ if (response.ContentStream is null or MemoryStream)
{
- using (var streamReader = new StreamReader(response.ContentStream, encoding))
- {
- content = streamReader.ReadToEnd();
- }
+ return;
}
- return content;
+ var bufferedStream = new MemoryStream();
+ response.ContentStream.CopyTo(bufferedStream);
+
+ // Dispose the unbuffered stream
+ response.ContentStream.Dispose();
+
+ // Reset the position of the buffered stream and set it on the response
+ bufferedStream.Position = 0;
+ response.ContentStream = bufferedStream;
}
internal static bool TryExtractErrorContent(Response response, out ResponseError? error, out IDictionary? data)
@@ -218,18 +224,9 @@ internal static bool TryExtractErrorContent(Response response, out ResponseError
data = null;
try
{
- string? content = null;
- if (response.ContentStream != null && response.ContentStream.CanSeek)
- {
- content = response.Content.ToString();
- }
- else
- {
- // this path should only happen in exceptional cases such as when
- // the RFE ctor was called directly by client or customer code with an un-buffered response.
- // Generated code would never do this.
- content = ReadContent(response);
- }
+ // The response content is buffered at this point.
+ string? content = response.Content.ToString();
+
// Optimistic check for JSON object we expect
if (content == null || !content.StartsWith("{", StringComparison.OrdinalIgnoreCase))
{
diff --git a/sdk/core/Azure.Core/tests/FailedResponseExceptionTests.cs b/sdk/core/Azure.Core/tests/FailedResponseExceptionTests.cs
index af6e3aa5bd86c..d0a7092be66af 100644
--- a/sdk/core/Azure.Core/tests/FailedResponseExceptionTests.cs
+++ b/sdk/core/Azure.Core/tests/FailedResponseExceptionTests.cs
@@ -40,6 +40,12 @@ public async Task FormatsResponse()
RequestFailedException exception = await ClientDiagnostics.CreateRequestFailedExceptionAsync(response);
Assert.AreEqual(formattedResponse, exception.Message);
+
+ Assert.IsTrue(exception.Response.Headers.TryGetValue("Custom-Header", out var value));
+ Assert.AreEqual("Value", value);
+ Assert.IsTrue(exception.Response.Headers.TryGetValue("x-ms-requestId", out var requestId));
+ Assert.AreEqual("123", requestId);
+ Assert.IsNull(exception.Response.ContentStream);
}
[Test]
@@ -60,6 +66,12 @@ public void FormatsResponse_ResponseCtor()
RequestFailedException exception = new RequestFailedException(response);
Assert.AreEqual(formattedResponse, exception.Message);
+
+ Assert.IsTrue(exception.Response.Headers.TryGetValue("Custom-Header", out var value));
+ Assert.AreEqual("Value", value);
+ Assert.IsTrue(exception.Response.Headers.TryGetValue("x-ms-requestId", out var requestId));
+ Assert.AreEqual("123", requestId);
+ Assert.IsNull(exception.Response.ContentStream);
}
[Test]
@@ -79,6 +91,12 @@ public void FormatsResponseWithoutSanitizer_ResponseCtor()
RequestFailedException exception = new RequestFailedException(response);
Assert.AreEqual(formattedResponse, exception.Message);
+
+ Assert.IsTrue(exception.Response.Headers.TryGetValue("Custom-Header", out var value));
+ Assert.AreEqual("Value", value);
+ Assert.IsTrue(exception.Response.Headers.TryGetValue("x-ms-requestId", out var requestId));
+ Assert.AreEqual("123", requestId);
+ Assert.IsNull(exception.Response.ContentStream);
}
[Test]
@@ -141,6 +159,14 @@ public async Task FormatsResponseContentForTextContentTypes()
RequestFailedException exception = await ClientDiagnostics.CreateRequestFailedExceptionAsync(response);
Assert.AreEqual(formattedResponse, exception.Message);
+
+ Assert.IsTrue(exception.Response.Headers.TryGetValue("Content-Type", out var value));
+ Assert.AreEqual("text/json", value);
+ Assert.IsTrue(exception.Response.Headers.TryGetValue("x-ms-requestId", out var requestId));
+ Assert.AreEqual("123", requestId);
+ Assert.IsInstanceOf(exception.Response.ContentStream);
+ Assert.AreEqual(0, exception.Response.ContentStream.Position);
+ Assert.AreEqual("{\"errorCode\": 1}", response.Content.ToString());
}
[Test]
@@ -160,6 +186,10 @@ public async Task DoesntFormatsResponseContentForNonTextContentTypes()
RequestFailedException exception = await ClientDiagnostics.CreateRequestFailedExceptionAsync(response);
Assert.AreEqual(formattedResponse, exception.Message);
+
+ Assert.IsInstanceOf(exception.Response.ContentStream);
+ Assert.AreEqual(0, exception.Response.ContentStream.Position);
+ Assert.AreEqual("{\"errorCode\": 1}", response.Content.ToString());
}
[Test]
@@ -320,6 +350,10 @@ public void ParsesJsonErrors_ResponseCtor_Stream([Values(true, false)] bool canS
RequestFailedException exception = new RequestFailedException(response);
Assert.AreEqual(formattedResponse, exception.Message);
Assert.AreEqual("StatusCode", exception.ErrorCode);
+
+ Assert.IsInstanceOf(exception.Response.ContentStream);
+ Assert.AreEqual(0, exception.Response.ContentStream.Position);
+ Assert.AreEqual("{ \"error\": { \"code\":\"StatusCode\", \"message\":\"Custom message\" }}", response.Content.ToString());
}
[Test]
@@ -345,6 +379,10 @@ public async Task ParsesJsonErrors_ResponseCtor_StreamAsync([Values(true, false)
RequestFailedException exception = new RequestFailedException(response);
Assert.AreEqual(formattedResponse, exception.Message);
Assert.AreEqual("StatusCode", exception.ErrorCode);
+
+ Assert.IsInstanceOf(exception.Response.ContentStream);
+ Assert.AreEqual(0, exception.Response.ContentStream.Position);
+ Assert.AreEqual("{ \"error\": { \"code\":\"StatusCode\", \"message\":\"Custom message\" }}", response.Content.ToString());
}
[Test]
@@ -418,7 +456,7 @@ private Stream GetStream(bool isSeekable, string content)
false => new UnSeekableStream(_stream)
};
}
- private class UnSeekableStream : MemoryStream
+ private class UnSeekableStream : Stream
{
private readonly MemoryStream _stream;
public UnSeekableStream(MemoryStream stream)
@@ -454,10 +492,6 @@ public override void Close()
{
_stream.Close();
}
- public override bool TryGetBuffer(out ArraySegment buffer)
- {
- return _stream.TryGetBuffer(out buffer);
- }
public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken)
{
@@ -481,6 +515,11 @@ public override void EndWrite(IAsyncResult asyncResult)
_stream.EndWrite(asyncResult);
}
+ public override void Flush()
+ {
+ _stream.Flush();
+ }
+
public override bool Equals(object obj)
{
return _stream.Equals(obj);
@@ -511,6 +550,16 @@ public override int ReadByte()
return _stream.ReadByte();
}
+ public override long Seek(long offset, SeekOrigin origin)
+ {
+ return _stream.Seek(offset, origin);
+ }
+
+ public override void SetLength(long value)
+ {
+ _stream.SetLength(value);
+ }
+
public override string ToString()
{
return _stream.ToString();
From 111ab1b8fcac00fa418a3b5001a0ac1f7a625f10 Mon Sep 17 00:00:00 2001
From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Date: Tue, 25 Apr 2023 15:13:12 -0700
Subject: [PATCH 02/16] Use ctor
---
.../src/TestEnvironment.cs | 4 +-
.../src/Shared/ClientDiagnostics.cs | 159 ------------------
.../src/Shared/OperationInternalBase.cs | 4 -
.../src/Shared/OperationInternalOfT.cs | 2 +-
.../Resources/Custom/ArmRestApiCollection.cs | 2 -
.../src/Resources/Custom/GenericResource.cs | 4 +-
.../Custom/GenericResourceCollection.cs | 4 +-
.../Custom/RestOperations/RestOperations.cs | 4 +-
8 files changed, 9 insertions(+), 174 deletions(-)
diff --git a/sdk/core/Azure.Core.TestFramework/src/TestEnvironment.cs b/sdk/core/Azure.Core.TestFramework/src/TestEnvironment.cs
index fa1b62a3fc931..bea5286ff8151 100644
--- a/sdk/core/Azure.Core.TestFramework/src/TestEnvironment.cs
+++ b/sdk/core/Azure.Core.TestFramework/src/TestEnvironment.cs
@@ -344,7 +344,7 @@ private async Task ExtendResourceGroupExpirationAsync()
// unexpected response => throw an exception
if (response.Status != 200)
{
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response);
+ throw new RequestFailedException(response);
}
// parse the response
@@ -392,7 +392,7 @@ private async Task ExtendResourceGroupExpirationAsync()
response = await pipeline.SendRequestAsync(request, CancellationToken.None);
if (response.Status != 200)
{
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response);
+ throw new RequestFailedException(response);
}
}
}
diff --git a/sdk/core/Azure.Core/src/Shared/ClientDiagnostics.cs b/sdk/core/Azure.Core/src/Shared/ClientDiagnostics.cs
index 9063d7d0e84d3..81a1859b1b973 100644
--- a/sdk/core/Azure.Core/src/Shared/ClientDiagnostics.cs
+++ b/sdk/core/Azure.Core/src/Shared/ClientDiagnostics.cs
@@ -18,10 +18,6 @@ namespace Azure.Core.Pipeline
{
internal class ClientDiagnostics : DiagnosticScopeFactory
{
- private const string DefaultMessage = "Service request failed.";
-
- private readonly HttpMessageSanitizer _sanitizer;
-
///
/// Initializes a new instance of the class.
///
@@ -55,7 +51,6 @@ public ClientDiagnostics(ClientOptions options, bool? suppressNestedClientActivi
public ClientDiagnostics(string optionsNamespace, string? providerNamespace, DiagnosticsOptions diagnosticsOptions, bool? suppressNestedClientActivities = null)
: base(optionsNamespace, providerNamespace, diagnosticsOptions.IsDistributedTracingEnabled, suppressNestedClientActivities.GetValueOrDefault(false))
{
- _sanitizer = CreateMessageSanitizer(diagnosticsOptions);
}
internal static HttpMessageSanitizer CreateMessageSanitizer(DiagnosticsOptions diagnostics)
@@ -65,154 +60,6 @@ internal static HttpMessageSanitizer CreateMessageSanitizer(DiagnosticsOptions d
diagnostics.LoggedHeaderNames.ToArray());
}
- internal static ResponseError? ExtractAzureErrorContent(string? content)
- {
- try
- {
- // Optimistic check for JSON object we expect
- if (content == null ||
- !content.StartsWith("{", StringComparison.OrdinalIgnoreCase)) return null;
-
- return JsonSerializer.Deserialize(content)?.Error;
- }
- catch (Exception)
- {
- // Ignore any failures - unexpected content will be
- // included verbatim in the detailed error message
- }
-
- return null;
- }
-
- public async ValueTask CreateRequestFailedExceptionAsync(Response response, ResponseError? error = null, IDictionary? additionalInfo = null, Exception? innerException = null)
- {
- if (GetType() == typeof(ClientDiagnostics) && error is null && additionalInfo is null)
- {
- return new RequestFailedException(response, innerException);
- }
-
- var content = await ReadContentAsync(response, true).ConfigureAwait(false);
- return CreateRequestFailedExceptionWithContent(response, error, content, additionalInfo, innerException);
- }
-
- public RequestFailedException CreateRequestFailedException(Response response, ResponseError? error = null, IDictionary? additionalInfo = null, Exception? innerException = null)
- {
- if (GetType() == typeof(ClientDiagnostics) && error is null && additionalInfo is null)
- {
- return new RequestFailedException(response, innerException);
- }
-
- string? content = ReadContentAsync(response, false).EnsureCompleted();
- return CreateRequestFailedExceptionWithContent(response, error, content, additionalInfo, innerException);
- }
-
- private RequestFailedException CreateRequestFailedExceptionWithContent(
- Response response,
- ResponseError? error = null,
- string? content = null,
- IDictionary? additionalInfo = null,
- Exception? innerException = null)
- {
- error ??= ExtractAzureErrorContent(content);
- var formatMessage = CreateRequestFailedMessageWithContent(response, error, content, additionalInfo, _sanitizer);
- var exception = new RequestFailedException(response.Status, formatMessage, error?.Code, innerException);
-
- if (additionalInfo != null)
- {
- foreach (KeyValuePair keyValuePair in additionalInfo)
- {
- exception.Data.Add(keyValuePair.Key, keyValuePair.Value);
- }
- }
-
- return exception;
- }
-
- public async ValueTask CreateRequestFailedMessageAsync(Response response, ResponseError? error, IDictionary? additionalInfo, bool async)
- {
- var content = await ReadContentAsync(response, async).ConfigureAwait(false);
- return CreateRequestFailedMessageWithContent(response, error, content, additionalInfo, _sanitizer);
- }
-
- internal static string CreateRequestFailedMessageWithContent(Response response, ResponseError? error, string? content, IDictionary? additionalInfo, HttpMessageSanitizer sanitizer)
- {
- StringBuilder messageBuilder = new StringBuilder();
-
- messageBuilder
- .AppendLine(error?.Message ?? DefaultMessage)
- .Append("Status: ")
- .Append(response.Status.ToString(CultureInfo.InvariantCulture));
-
- if (!string.IsNullOrEmpty(response.ReasonPhrase))
- {
- messageBuilder.Append(" (")
- .Append(response.ReasonPhrase)
- .AppendLine(")");
- }
- else
- {
- messageBuilder.AppendLine();
- }
-
- if (!string.IsNullOrWhiteSpace(error?.Code))
- {
- messageBuilder.Append("ErrorCode: ")
- .Append(error?.Code)
- .AppendLine();
- }
-
- if (additionalInfo != null && additionalInfo.Count > 0)
- {
- messageBuilder
- .AppendLine()
- .AppendLine("Additional Information:");
- foreach (KeyValuePair info in additionalInfo)
- {
- messageBuilder
- .Append(info.Key)
- .Append(": ")
- .AppendLine(info.Value);
- }
- }
-
- if (content != null)
- {
- messageBuilder
- .AppendLine()
- .AppendLine("Content:")
- .AppendLine(content);
- }
-
- messageBuilder
- .AppendLine()
- .AppendLine("Headers:");
-
- foreach (HttpHeader responseHeader in response.Headers)
- {
- string headerValue = sanitizer.SanitizeHeader(responseHeader.Name, responseHeader.Value);
- string header = $"{responseHeader.Name}: {headerValue}";
- messageBuilder.AppendLine(header);
- }
-
- return messageBuilder.ToString();
- }
-
- internal static async ValueTask ReadContentAsync(Response response, bool async)
- {
- string? content = null;
-
- if (response.ContentStream != null &&
- ContentTypeUtilities.TryGetTextEncoding(response.Headers.ContentType, out var encoding))
- {
- using (var streamReader = new StreamReader(response.ContentStream, encoding))
- {
- content = async ? await streamReader.ReadToEndAsync().ConfigureAwait(false) : streamReader.ReadToEnd();
- }
- }
-
- return content;
- }
-
internal static string? GetResourceProviderNamespace(Assembly assembly)
{
foreach (var customAttribute in assembly.GetCustomAttributes(true))
@@ -227,11 +74,5 @@ internal static string CreateRequestFailedMessageWithContent(Response response,
return null;
}
-
- private class ErrorResponse
- {
- [JsonPropertyName("error")]
- public ResponseError? Error { get; set; }
- }
}
}
diff --git a/sdk/core/Azure.Core/src/Shared/OperationInternalBase.cs b/sdk/core/Azure.Core/src/Shared/OperationInternalBase.cs
index 7781deee28640..dad6480c22ce7 100644
--- a/sdk/core/Azure.Core/src/Shared/OperationInternalBase.cs
+++ b/sdk/core/Azure.Core/src/Shared/OperationInternalBase.cs
@@ -230,9 +230,5 @@ protected DiagnosticScope CreateScope(string scopeName)
scope.Start();
return scope;
}
-
- protected async ValueTask CreateException(bool async, Response response) => async
- ? await _diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false)
- : _diagnostics.CreateRequestFailedException(response);
}
}
diff --git a/sdk/core/Azure.Core/src/Shared/OperationInternalOfT.cs b/sdk/core/Azure.Core/src/Shared/OperationInternalOfT.cs
index c4666e788c3da..66c7a71e561ac 100644
--- a/sdk/core/Azure.Core/src/Shared/OperationInternalOfT.cs
+++ b/sdk/core/Azure.Core/src/Shared/OperationInternalOfT.cs
@@ -281,7 +281,7 @@ protected override async ValueTask UpdateStatusAsync(bool async, Cance
if (!state.HasSucceeded && state.OperationFailedException == null)
{
- state = OperationState.Failure(state.RawResponse, await CreateException(async, state.RawResponse).ConfigureAwait(false));
+ state = OperationState.Failure(state.RawResponse, new RequestFailedException(state.RawResponse));
}
asyncLock.SetValue(state);
diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/ArmRestApiCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/ArmRestApiCollection.cs
index b94faa635c0c3..33570d8e8f680 100644
--- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/ArmRestApiCollection.cs
+++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/ArmRestApiCollection.cs
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
-//
-
#nullable disable
using System;
diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/GenericResource.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/GenericResource.cs
index 54f9f402fa88b..d3ab3aa863907 100644
--- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/GenericResource.cs
+++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/GenericResource.cs
@@ -89,7 +89,7 @@ public async virtual Task> GetAsync(CancellationToken
var apiVersion = await GetApiVersionAsync(cancellationToken).ConfigureAwait(false);
var response = await _resourcesRestClient.GetByIdAsync(Id, apiVersion, cancellationToken).ConfigureAwait(false);
if (response.Value == null)
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
+ throw new RequestFailedException(response.GetRawResponse());
return Response.FromValue(new GenericResource(Client, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -113,7 +113,7 @@ public virtual Response Get(CancellationToken cancellationToken
var apiVersion = GetApiVersion(cancellationToken);
var response = _resourcesRestClient.GetById(Id, apiVersion, cancellationToken);
if (response.Value == null)
- throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
+ throw new RequestFailedException(response.GetRawResponse());
return Response.FromValue(new GenericResource(Client, response.Value), response.GetRawResponse());
}
catch (Exception e)
diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/GenericResourceCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/GenericResourceCollection.cs
index dcae2e1806664..21a02e378e007 100644
--- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/GenericResourceCollection.cs
+++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/GenericResourceCollection.cs
@@ -138,7 +138,7 @@ public virtual Response Get(ResourceIdentifier resourceId, Canc
var apiVersion = GetApiVersion(new ResourceIdentifier(resourceId), cancellationToken);
var response = _resourcesRestClient.GetById(resourceId, apiVersion, cancellationToken);
if (response.Value == null)
- throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
+ throw new RequestFailedException(response.GetRawResponse());
return Response.FromValue(new GenericResource(Client, response.Value), response.GetRawResponse());
}
catch (Exception e)
@@ -169,7 +169,7 @@ public async virtual Task> GetAsync(ResourceIdentifier
var apiVersion = await GetApiVersionAsync(new ResourceIdentifier(resourceId), cancellationToken).ConfigureAwait(false);
var response = await _resourcesRestClient.GetByIdAsync(resourceId, apiVersion, cancellationToken).ConfigureAwait(false);
if (response.Value == null)
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
+ throw new RequestFailedException(response.GetRawResponse());
return Response.FromValue(new GenericResource(Client, response.Value), response.GetRawResponse());
}
catch (Exception e)
diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/RestOperations/RestOperations.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/RestOperations/RestOperations.cs
index 7821f8928ccd2..9652d2393f588 100644
--- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/RestOperations/RestOperations.cs
+++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/RestOperations/RestOperations.cs
@@ -80,7 +80,7 @@ public async Task> ListAsync(CancellationToken ca
return Response.FromValue(value, message.Response);
}
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -100,7 +100,7 @@ public Response List(CancellationToken cancellationToken =
return Response.FromValue(value, message.Response);
}
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
}
From cfe6cda6a302ec7674f6ce20f6187a73379fc4c6 Mon Sep 17 00:00:00 2001
From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Date: Tue, 25 Apr 2023 16:29:43 -0700
Subject: [PATCH 03/16] Fix tests
---
.../tests/FailedResponseExceptionTests.cs | 59 +++++++++++--------
.../Resources/Custom/ArmRestApiCollection.cs | 1 -
2 files changed, 35 insertions(+), 25 deletions(-)
diff --git a/sdk/core/Azure.Core/tests/FailedResponseExceptionTests.cs b/sdk/core/Azure.Core/tests/FailedResponseExceptionTests.cs
index d0a7092be66af..698b386e43835 100644
--- a/sdk/core/Azure.Core/tests/FailedResponseExceptionTests.cs
+++ b/sdk/core/Azure.Core/tests/FailedResponseExceptionTests.cs
@@ -23,7 +23,7 @@ public class FailedResponseExceptionTests
private static HttpMessageSanitizer Sanitizer = new TestClientOption().Sanitizer;
[Test]
- public async Task FormatsResponse()
+ public void FormatsResponse()
{
var formattedResponse =
"Service request failed." + s_nl +
@@ -38,7 +38,7 @@ public async Task FormatsResponse()
response.AddHeader(new HttpHeader("x-ms-requestId", "123"));
response.Sanitizer = Sanitizer;
- RequestFailedException exception = await ClientDiagnostics.CreateRequestFailedExceptionAsync(response);
+ RequestFailedException exception = new RequestFailedException(response);
Assert.AreEqual(formattedResponse, exception.Message);
Assert.IsTrue(exception.Response.Headers.TryGetValue("Custom-Header", out var value));
@@ -100,7 +100,7 @@ public void FormatsResponseWithoutSanitizer_ResponseCtor()
}
[Test]
- public async Task HeadersAreSanitized()
+ public void HeadersAreSanitized()
{
var formattedResponse =
"Service request failed." + s_nl +
@@ -114,7 +114,7 @@ public async Task HeadersAreSanitized()
response.AddHeader(new HttpHeader("Custom-Header-2", "Value"));
response.AddHeader(new HttpHeader("x-ms-requestId-2", "123"));
- RequestFailedException exception = await ClientDiagnostics.CreateRequestFailedExceptionAsync(response);
+ RequestFailedException exception = new RequestFailedException(response);
Assert.AreEqual(formattedResponse, exception.Message);
}
@@ -138,7 +138,7 @@ public void HeadersAreSanitized_ResponseCtor()
}
[Test]
- public async Task FormatsResponseContentForTextContentTypes()
+ public void FormatsResponseContentForTextContentTypes()
{
var formattedResponse =
"Service request failed." + s_nl +
@@ -157,7 +157,7 @@ public async Task FormatsResponseContentForTextContentTypes()
response.SetContent("{\"errorCode\": 1}");
response.Sanitizer = Sanitizer;
- RequestFailedException exception = await ClientDiagnostics.CreateRequestFailedExceptionAsync(response);
+ RequestFailedException exception = new RequestFailedException(response);
Assert.AreEqual(formattedResponse, exception.Message);
Assert.IsTrue(exception.Response.Headers.TryGetValue("Content-Type", out var value));
@@ -170,7 +170,7 @@ public async Task FormatsResponseContentForTextContentTypes()
}
[Test]
- public async Task DoesntFormatsResponseContentForNonTextContentTypes()
+ public void DoesntFormatsResponseContentForNonTextContentTypes()
{
var formattedResponse =
"Service request failed." + s_nl +
@@ -184,7 +184,7 @@ public async Task DoesntFormatsResponseContentForNonTextContentTypes()
response.SetContent("{\"errorCode\": 1}");
response.Sanitizer = Sanitizer;
- RequestFailedException exception = await ClientDiagnostics.CreateRequestFailedExceptionAsync(response);
+ RequestFailedException exception = new RequestFailedException(response);
Assert.AreEqual(formattedResponse, exception.Message);
Assert.IsInstanceOf(exception.Response.ContentStream);
@@ -193,7 +193,7 @@ public async Task DoesntFormatsResponseContentForNonTextContentTypes()
}
[Test]
- public async Task IncludesErrorCodeInMessageIfAvailable()
+ public void IncludesErrorCodeInMessageIfAvailable()
{
var formattedResponse =
"Service request failed." + s_nl +
@@ -207,13 +207,15 @@ public async Task IncludesErrorCodeInMessageIfAvailable()
var response = new MockResponse(210, "Reason");
response.AddHeader(new HttpHeader("Custom-Header", "Value"));
response.AddHeader(new HttpHeader("x-ms-requestId", "123"));
+ response.SetContent("{ \"error\": { \"code\":\"CUSTOM CODE\" }}");
+ response.Sanitizer = Sanitizer;
- RequestFailedException exception = await ClientDiagnostics.CreateRequestFailedExceptionAsync(response, new ResponseError("CUSTOM CODE", null));
+ RequestFailedException exception = new RequestFailedException(response);
Assert.AreEqual(formattedResponse, exception.Message);
}
[Test]
- public async Task IncludesAdditionalInformationIfAvailable()
+ public void IncludesAdditionalInformationIfAvailable()
{
var formattedResponse =
"Service request failed." + s_nl +
@@ -230,12 +232,11 @@ public async Task IncludesAdditionalInformationIfAvailable()
var response = new MockResponse(210, "Reason");
response.AddHeader(new HttpHeader("Custom-Header", "Value"));
response.AddHeader(new HttpHeader("x-ms-requestId", "123"));
+ response.SetContent("{ \"a\": \"a-value\", \"b\": \"b-value\" }");
+ response.Sanitizer = Sanitizer;
+ response.RequestFailedDetailsParser = new CustomParser();
- RequestFailedException exception = await ClientDiagnostics.CreateRequestFailedExceptionAsync(response, additionalInfo: new Dictionary()
- {
- {"a", "a-value"},
- {"b", "b-value"},
- });
+ RequestFailedException exception = new RequestFailedException(response);
Assert.AreEqual(formattedResponse, exception.Message);
Assert.AreEqual("a-value", exception.Data["a"]);
@@ -243,7 +244,7 @@ public async Task IncludesAdditionalInformationIfAvailable()
}
[Test]
- public async Task IncludesInnerException()
+ public void IncludesInnerException()
{
var formattedResponse =
"Service request failed." + s_nl +
@@ -259,7 +260,7 @@ public async Task IncludesInnerException()
response.Sanitizer = Sanitizer;
var innerException = new Exception();
- RequestFailedException exception = await ClientDiagnostics.CreateRequestFailedExceptionAsync(response, innerException: innerException);
+ RequestFailedException exception = new RequestFailedException(response, innerException: innerException);
Assert.AreEqual(formattedResponse, exception.Message);
Assert.AreEqual(innerException, exception.InnerException);
}
@@ -281,7 +282,7 @@ public void RequestFailedExceptionIsSerializeable()
}
[Test]
- public async Task ParsesJsonErrors()
+ public void ParsesJsonErrors()
{
var formattedResponse =
"Custom message" + s_nl +
@@ -299,7 +300,7 @@ public async Task ParsesJsonErrors()
response.AddHeader(new HttpHeader("Content-Type", "text/json"));
response.Sanitizer = Sanitizer;
- RequestFailedException exception = await ClientDiagnostics.CreateRequestFailedExceptionAsync(response);
+ RequestFailedException exception = new RequestFailedException(response);
Assert.AreEqual(formattedResponse, exception.Message);
Assert.AreEqual("StatusCode", exception.ErrorCode);
}
@@ -386,7 +387,7 @@ public async Task ParsesJsonErrors_ResponseCtor_StreamAsync([Values(true, false)
}
[Test]
- public async Task IgnoresInvalidJsonErrors()
+ public void IgnoresInvalidJsonErrors()
{
var formattedResponse =
"Service request failed." + s_nl +
@@ -403,12 +404,12 @@ public async Task IgnoresInvalidJsonErrors()
response.AddHeader(new HttpHeader("Content-Type", "text/json"));
response.Sanitizer = Sanitizer;
- RequestFailedException exception = await ClientDiagnostics.CreateRequestFailedExceptionAsync(response);
+ RequestFailedException exception = new RequestFailedException(response);
Assert.AreEqual(formattedResponse, exception.Message);
}
[Test]
- public async Task IgnoresNonStandardJson()
+ public void IgnoresNonStandardJson()
{
var formattedResponse =
"Service request failed." + s_nl +
@@ -425,7 +426,7 @@ public async Task IgnoresNonStandardJson()
response.AddHeader(new HttpHeader("Content-Type", "text/json"));
response.Sanitizer = Sanitizer;
- RequestFailedException exception = await ClientDiagnostics.CreateRequestFailedExceptionAsync(response);
+ RequestFailedException exception = new RequestFailedException(response);
Assert.AreEqual(formattedResponse, exception.Message);
}
@@ -580,5 +581,15 @@ public override void WriteByte(byte value)
_stream.WriteByte(value);
}
}
+
+ private class CustomParser : RequestFailedDetailsParser
+ {
+ public override bool TryParse(Response response, out ResponseError error, out IDictionary data)
+ {
+ RequestFailedException.TryExtractErrorContent(response, out error, out data);
+ data = response.Content.ToObjectFromJson>();
+ return true;
+ }
+ }
}
}
diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/ArmRestApiCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/ArmRestApiCollection.cs
index 33570d8e8f680..25e587549eccf 100644
--- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/ArmRestApiCollection.cs
+++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Custom/ArmRestApiCollection.cs
@@ -42,7 +42,6 @@ internal ArmRestApiCollection(ArmResource operation, string nameSpace)
_providerCollection = new ResourceProviderCollection(Client.GetSubscriptionResource(Id));
}
-
private RestOperations GetRestClient(CancellationToken cancellationToken = default)
{
return _restClient ??= new RestOperations(
From bc4bb5dfe7787c9df82307c52d079dba526431ec Mon Sep 17 00:00:00 2001
From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Date: Tue, 25 Apr 2023 16:33:40 -0700
Subject: [PATCH 04/16] Use a method
---
sdk/core/Azure.Core/api/Azure.Core.net461.cs | 2 +-
sdk/core/Azure.Core/api/Azure.Core.net5.0.cs | 2 +-
sdk/core/Azure.Core/api/Azure.Core.net6.0.cs | 2 +-
sdk/core/Azure.Core/api/Azure.Core.netcoreapp2.1.cs | 2 +-
sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs | 2 +-
sdk/core/Azure.Core/src/RequestFailedException.cs | 9 +++++++--
6 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/sdk/core/Azure.Core/api/Azure.Core.net461.cs b/sdk/core/Azure.Core/api/Azure.Core.net461.cs
index 4c304f46e9c4c..d4d2ab9fe00c0 100644
--- a/sdk/core/Azure.Core/api/Azure.Core.net461.cs
+++ b/sdk/core/Azure.Core/api/Azure.Core.net461.cs
@@ -227,9 +227,9 @@ protected RequestFailedException(System.Runtime.Serialization.SerializationInfo
public RequestFailedException(string message) { }
public RequestFailedException(string message, System.Exception? innerException) { }
public string? ErrorCode { get { throw null; } }
- public Azure.Response? Response { get { throw null; } }
public int Status { get { throw null; } }
public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
+ public Azure.Response? GetRawResponse() { throw null; }
}
public abstract partial class Response : System.IDisposable
{
diff --git a/sdk/core/Azure.Core/api/Azure.Core.net5.0.cs b/sdk/core/Azure.Core/api/Azure.Core.net5.0.cs
index 702382dcedeec..a5675287237a2 100644
--- a/sdk/core/Azure.Core/api/Azure.Core.net5.0.cs
+++ b/sdk/core/Azure.Core/api/Azure.Core.net5.0.cs
@@ -227,9 +227,9 @@ protected RequestFailedException(System.Runtime.Serialization.SerializationInfo
public RequestFailedException(string message) { }
public RequestFailedException(string message, System.Exception? innerException) { }
public string? ErrorCode { get { throw null; } }
- public Azure.Response? Response { get { throw null; } }
public int Status { get { throw null; } }
public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
+ public Azure.Response? GetRawResponse() { throw null; }
}
public abstract partial class Response : System.IDisposable
{
diff --git a/sdk/core/Azure.Core/api/Azure.Core.net6.0.cs b/sdk/core/Azure.Core/api/Azure.Core.net6.0.cs
index 702382dcedeec..a5675287237a2 100644
--- a/sdk/core/Azure.Core/api/Azure.Core.net6.0.cs
+++ b/sdk/core/Azure.Core/api/Azure.Core.net6.0.cs
@@ -227,9 +227,9 @@ protected RequestFailedException(System.Runtime.Serialization.SerializationInfo
public RequestFailedException(string message) { }
public RequestFailedException(string message, System.Exception? innerException) { }
public string? ErrorCode { get { throw null; } }
- public Azure.Response? Response { get { throw null; } }
public int Status { get { throw null; } }
public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
+ public Azure.Response? GetRawResponse() { throw null; }
}
public abstract partial class Response : System.IDisposable
{
diff --git a/sdk/core/Azure.Core/api/Azure.Core.netcoreapp2.1.cs b/sdk/core/Azure.Core/api/Azure.Core.netcoreapp2.1.cs
index 4c304f46e9c4c..d4d2ab9fe00c0 100644
--- a/sdk/core/Azure.Core/api/Azure.Core.netcoreapp2.1.cs
+++ b/sdk/core/Azure.Core/api/Azure.Core.netcoreapp2.1.cs
@@ -227,9 +227,9 @@ protected RequestFailedException(System.Runtime.Serialization.SerializationInfo
public RequestFailedException(string message) { }
public RequestFailedException(string message, System.Exception? innerException) { }
public string? ErrorCode { get { throw null; } }
- public Azure.Response? Response { get { throw null; } }
public int Status { get { throw null; } }
public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
+ public Azure.Response? GetRawResponse() { throw null; }
}
public abstract partial class Response : System.IDisposable
{
diff --git a/sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs b/sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs
index 4c304f46e9c4c..d4d2ab9fe00c0 100644
--- a/sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs
+++ b/sdk/core/Azure.Core/api/Azure.Core.netstandard2.0.cs
@@ -227,9 +227,9 @@ protected RequestFailedException(System.Runtime.Serialization.SerializationInfo
public RequestFailedException(string message) { }
public RequestFailedException(string message, System.Exception? innerException) { }
public string? ErrorCode { get { throw null; } }
- public Azure.Response? Response { get { throw null; } }
public int Status { get { throw null; } }
public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
+ public Azure.Response? GetRawResponse() { throw null; }
}
public abstract partial class Response : System.IDisposable
{
diff --git a/sdk/core/Azure.Core/src/RequestFailedException.cs b/sdk/core/Azure.Core/src/RequestFailedException.cs
index 0a81bf8803632..bc293de3c27f2 100644
--- a/sdk/core/Azure.Core/src/RequestFailedException.cs
+++ b/sdk/core/Azure.Core/src/RequestFailedException.cs
@@ -34,7 +34,7 @@ public class RequestFailedException : Exception, ISerializable
///
/// Gets the response, if any, that led to the exception.
///
- public Response? Response { get; }
+ private readonly Response? _response;
/// Initializes a new instance of the class with a specified error message.
/// The message that describes the error.
@@ -110,7 +110,7 @@ public RequestFailedException(Response response)
public RequestFailedException(Response response, Exception? innerException)
: this(response.Status, GetRequestFailedExceptionContent(response), innerException)
{
- Response = response;
+ _response = response;
}
///
@@ -132,6 +132,11 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont
base.GetObjectData(info, context);
}
+ ///
+ /// Gets the response, if any, that led to the exception.
+ ///
+ public Response? GetRawResponse() => _response;
+
internal static (string FormattedError, string? ErrorCode, IDictionary? Data) GetRequestFailedExceptionContent(Response response)
{
BufferResponseIfNeeded(response);
From 2b67600610009ef93bca67735efe4c35fc9898d4 Mon Sep 17 00:00:00 2001
From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Date: Tue, 25 Apr 2023 16:39:28 -0700
Subject: [PATCH 05/16] change log
---
sdk/core/Azure.Core/CHANGELOG.md | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sdk/core/Azure.Core/CHANGELOG.md b/sdk/core/Azure.Core/CHANGELOG.md
index fc7b34aa83b61..f02f87fc7e389 100644
--- a/sdk/core/Azure.Core/CHANGELOG.md
+++ b/sdk/core/Azure.Core/CHANGELOG.md
@@ -4,6 +4,9 @@
### Features Added
+- Added the `GetRawResponse` method to `RequestFailedException`.
+- Added overloads of `Operation.WaitForCompletion` and `Operation.WaitForCompletionResponse` that take a `DelayStrategy`.
+
### Breaking Changes
### Bugs Fixed
From 0847dc211b3aa5d9b4f73d9c249759cb4f46e326 Mon Sep 17 00:00:00 2001
From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Date: Wed, 26 Apr 2023 13:48:48 -0700
Subject: [PATCH 06/16] Fix tests
---
.../tests/FailedResponseExceptionTests.cs | 53 +++++++++++--------
1 file changed, 30 insertions(+), 23 deletions(-)
diff --git a/sdk/core/Azure.Core/tests/FailedResponseExceptionTests.cs b/sdk/core/Azure.Core/tests/FailedResponseExceptionTests.cs
index 698b386e43835..03db4195159aa 100644
--- a/sdk/core/Azure.Core/tests/FailedResponseExceptionTests.cs
+++ b/sdk/core/Azure.Core/tests/FailedResponseExceptionTests.cs
@@ -41,11 +41,12 @@ public void FormatsResponse()
RequestFailedException exception = new RequestFailedException(response);
Assert.AreEqual(formattedResponse, exception.Message);
- Assert.IsTrue(exception.Response.Headers.TryGetValue("Custom-Header", out var value));
+ Response rawResponse = exception.GetRawResponse();
+ Assert.IsTrue(rawResponse.Headers.TryGetValue("Custom-Header", out var value));
Assert.AreEqual("Value", value);
- Assert.IsTrue(exception.Response.Headers.TryGetValue("x-ms-requestId", out var requestId));
+ Assert.IsTrue(rawResponse.Headers.TryGetValue("x-ms-requestId", out var requestId));
Assert.AreEqual("123", requestId);
- Assert.IsNull(exception.Response.ContentStream);
+ Assert.IsNull(rawResponse.ContentStream);
}
[Test]
@@ -67,11 +68,12 @@ public void FormatsResponse_ResponseCtor()
RequestFailedException exception = new RequestFailedException(response);
Assert.AreEqual(formattedResponse, exception.Message);
- Assert.IsTrue(exception.Response.Headers.TryGetValue("Custom-Header", out var value));
+ Response rawResponse = exception.GetRawResponse();
+ Assert.IsTrue(rawResponse.Headers.TryGetValue("Custom-Header", out var value));
Assert.AreEqual("Value", value);
- Assert.IsTrue(exception.Response.Headers.TryGetValue("x-ms-requestId", out var requestId));
+ Assert.IsTrue(rawResponse.Headers.TryGetValue("x-ms-requestId", out var requestId));
Assert.AreEqual("123", requestId);
- Assert.IsNull(exception.Response.ContentStream);
+ Assert.IsNull(rawResponse.ContentStream);
}
[Test]
@@ -92,11 +94,12 @@ public void FormatsResponseWithoutSanitizer_ResponseCtor()
RequestFailedException exception = new RequestFailedException(response);
Assert.AreEqual(formattedResponse, exception.Message);
- Assert.IsTrue(exception.Response.Headers.TryGetValue("Custom-Header", out var value));
+ Response rawResponse = exception.GetRawResponse();
+ Assert.IsTrue(rawResponse.Headers.TryGetValue("Custom-Header", out var value));
Assert.AreEqual("Value", value);
- Assert.IsTrue(exception.Response.Headers.TryGetValue("x-ms-requestId", out var requestId));
+ Assert.IsTrue(rawResponse.Headers.TryGetValue("x-ms-requestId", out var requestId));
Assert.AreEqual("123", requestId);
- Assert.IsNull(exception.Response.ContentStream);
+ Assert.IsNull(rawResponse.ContentStream);
}
[Test]
@@ -160,13 +163,14 @@ public void FormatsResponseContentForTextContentTypes()
RequestFailedException exception = new RequestFailedException(response);
Assert.AreEqual(formattedResponse, exception.Message);
- Assert.IsTrue(exception.Response.Headers.TryGetValue("Content-Type", out var value));
+ Response rawResponse = exception.GetRawResponse();
+ Assert.IsTrue(rawResponse.Headers.TryGetValue("Content-Type", out var value));
Assert.AreEqual("text/json", value);
- Assert.IsTrue(exception.Response.Headers.TryGetValue("x-ms-requestId", out var requestId));
+ Assert.IsTrue(rawResponse.Headers.TryGetValue("x-ms-requestId", out var requestId));
Assert.AreEqual("123", requestId);
- Assert.IsInstanceOf(exception.Response.ContentStream);
- Assert.AreEqual(0, exception.Response.ContentStream.Position);
- Assert.AreEqual("{\"errorCode\": 1}", response.Content.ToString());
+ Assert.IsInstanceOf(rawResponse.ContentStream);
+ Assert.AreEqual(0, rawResponse.ContentStream.Position);
+ Assert.AreEqual("{\"errorCode\": 1}", rawResponse.Content.ToString());
}
[Test]
@@ -186,10 +190,11 @@ public void DoesntFormatsResponseContentForNonTextContentTypes()
RequestFailedException exception = new RequestFailedException(response);
Assert.AreEqual(formattedResponse, exception.Message);
+ Response rawResponse = exception.GetRawResponse();
- Assert.IsInstanceOf(exception.Response.ContentStream);
- Assert.AreEqual(0, exception.Response.ContentStream.Position);
- Assert.AreEqual("{\"errorCode\": 1}", response.Content.ToString());
+ Assert.IsInstanceOf(rawResponse.ContentStream);
+ Assert.AreEqual(0, rawResponse.ContentStream.Position);
+ Assert.AreEqual("{\"errorCode\": 1}", rawResponse.Content.ToString());
}
[Test]
@@ -351,10 +356,11 @@ public void ParsesJsonErrors_ResponseCtor_Stream([Values(true, false)] bool canS
RequestFailedException exception = new RequestFailedException(response);
Assert.AreEqual(formattedResponse, exception.Message);
Assert.AreEqual("StatusCode", exception.ErrorCode);
+ Response rawResponse = exception.GetRawResponse();
- Assert.IsInstanceOf(exception.Response.ContentStream);
- Assert.AreEqual(0, exception.Response.ContentStream.Position);
- Assert.AreEqual("{ \"error\": { \"code\":\"StatusCode\", \"message\":\"Custom message\" }}", response.Content.ToString());
+ Assert.IsInstanceOf(rawResponse.ContentStream);
+ Assert.AreEqual(0, rawResponse.ContentStream.Position);
+ Assert.AreEqual("{ \"error\": { \"code\":\"StatusCode\", \"message\":\"Custom message\" }}", rawResponse.Content.ToString());
}
[Test]
@@ -381,9 +387,10 @@ public async Task ParsesJsonErrors_ResponseCtor_StreamAsync([Values(true, false)
Assert.AreEqual(formattedResponse, exception.Message);
Assert.AreEqual("StatusCode", exception.ErrorCode);
- Assert.IsInstanceOf(exception.Response.ContentStream);
- Assert.AreEqual(0, exception.Response.ContentStream.Position);
- Assert.AreEqual("{ \"error\": { \"code\":\"StatusCode\", \"message\":\"Custom message\" }}", response.Content.ToString());
+ Response rawResponse = exception.GetRawResponse();
+ Assert.IsInstanceOf(rawResponse.ContentStream);
+ Assert.AreEqual(0, rawResponse.ContentStream.Position);
+ Assert.AreEqual("{ \"error\": { \"code\":\"StatusCode\", \"message\":\"Custom message\" }}", rawResponse.Content.ToString());
}
[Test]
From 64e7d5ba9026e741ad2d55ed6d0aa33892efb966 Mon Sep 17 00:00:00 2001
From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Date: Wed, 26 Apr 2023 15:11:52 -0700
Subject: [PATCH 07/16] Update search
---
.../Azure.Search.Documents/src/SearchClient.cs | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/sdk/search/Azure.Search.Documents/src/SearchClient.cs b/sdk/search/Azure.Search.Documents/src/SearchClient.cs
index e63b203667af1..3f3792d21c6f7 100644
--- a/sdk/search/Azure.Search.Documents/src/SearchClient.cs
+++ b/sdk/search/Azure.Search.Documents/src/SearchClient.cs
@@ -705,9 +705,7 @@ private async Task> GetDocumentInternal(
return Response.FromValue(value, message.Response);
}
default:
- throw async ?
- await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false) :
- ClientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
catch (Exception e)
@@ -895,9 +893,7 @@ private async Task>> SearchInternal(
return Response.FromValue(results, message.Response);
}
default:
- throw async ?
- await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false) :
- ClientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
catch (Exception e)
@@ -1060,9 +1056,7 @@ private async Task>> SuggestInternal(
return Response.FromValue(suggestions, message.Response);
}
default:
- throw async ?
- await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false) :
- ClientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
catch (Exception e)
@@ -1391,9 +1385,7 @@ await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellat
return Response.FromValue(value, message.Response);
}
default:
- throw async ?
- await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false) :
- ClientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
catch (Exception e)
From 9d48d0e4c2bd5e6adaea42f18133322f24595ab5 Mon Sep 17 00:00:00 2001
From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Date: Wed, 26 Apr 2023 15:43:32 -0700
Subject: [PATCH 08/16] KeyVault
---
.../src/CertificateClient.cs | 4 ++--
.../src/DeleteCertificateOperation.cs | 6 +-----
.../src/RecoverDeletedCertificateOperation.cs | 6 +-----
.../src/Cryptography/KeyResolver.cs | 2 +-
.../Azure.Security.KeyVault.Keys/src/DeleteKeyOperation.cs | 6 +-----
.../src/RecoverDeletedKeyOperation.cs | 6 +-----
.../src/DeleteSecretOperation.cs | 6 +-----
.../src/RecoverDeletedSecretOperation.cs | 6 +-----
.../Azure.Security.KeyVault.Shared/src/KeyVaultPipeline.cs | 4 ++--
9 files changed, 11 insertions(+), 35 deletions(-)
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Certificates/src/CertificateClient.cs b/sdk/keyvault/Azure.Security.KeyVault.Certificates/src/CertificateClient.cs
index ca5f1f0c3885e..8d2491186f1d4 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Certificates/src/CertificateClient.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Certificates/src/CertificateClient.cs
@@ -1665,7 +1665,7 @@ internal virtual Response GetPendingCertificate(
return Response.FromValue(null, response);
default:
- throw _pipeline.Diagnostics.CreateRequestFailedException(response);
+ throw new RequestFailedException(response);
}
}
catch (Exception e)
@@ -1696,7 +1696,7 @@ internal virtual async Task> GetPending
return Response.FromValue(null, response);
default:
- throw await _pipeline.Diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false);
+ throw new RequestFailedException(response);
}
}
catch (Exception e)
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Certificates/src/DeleteCertificateOperation.cs b/sdk/keyvault/Azure.Security.KeyVault.Certificates/src/DeleteCertificateOperation.cs
index 175974e732f6d..e08a41bdf9775 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Certificates/src/DeleteCertificateOperation.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Certificates/src/DeleteCertificateOperation.cs
@@ -111,11 +111,7 @@ async ValueTask IOperation.UpdateStateAsync(bool async, Cancella
return OperationState.Pending(response);
default:
- RequestFailedException ex = async
- ? await _pipeline.Diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false)
- : _pipeline.Diagnostics.CreateRequestFailedException(response);
-
- return OperationState.Failure(response, ex);
+ return OperationState.Failure(response, new RequestFailedException(response));
}
}
}
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Certificates/src/RecoverDeletedCertificateOperation.cs b/sdk/keyvault/Azure.Security.KeyVault.Certificates/src/RecoverDeletedCertificateOperation.cs
index 11fcd7df578a2..7f4468db56af4 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Certificates/src/RecoverDeletedCertificateOperation.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Certificates/src/RecoverDeletedCertificateOperation.cs
@@ -101,11 +101,7 @@ async ValueTask IOperation.UpdateStateAsync(bool async, Cancella
return OperationState.Pending(response);
default:
- RequestFailedException ex = async
- ? await _pipeline.Diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false)
- : _pipeline.Diagnostics.CreateRequestFailedException(response);
-
- return OperationState.Failure(response, ex);
+ return OperationState.Failure(response, new RequestFailedException(response));
}
}
}
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Keys/src/Cryptography/KeyResolver.cs b/sdk/keyvault/Azure.Security.KeyVault.Keys/src/Cryptography/KeyResolver.cs
index 60583c9c635b5..05b6ebc17b3f1 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Keys/src/Cryptography/KeyResolver.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Keys/src/Cryptography/KeyResolver.cs
@@ -173,7 +173,7 @@ private Response ParseResponse(Response response, T result)
// To use a key contained within a secret, the "get" permission is required to retrieve the key material.
return Response.FromValue(default, response);
default:
- throw _clientDiagnostics.CreateRequestFailedException(response);
+ throw new RequestFailedException(response);
}
}
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Keys/src/DeleteKeyOperation.cs b/sdk/keyvault/Azure.Security.KeyVault.Keys/src/DeleteKeyOperation.cs
index 96b9d3c5dfe32..c35af7cc1c9a6 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Keys/src/DeleteKeyOperation.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Keys/src/DeleteKeyOperation.cs
@@ -111,11 +111,7 @@ async ValueTask IOperation.UpdateStateAsync(bool async, Cancella
return OperationState.Pending(response);
default:
- RequestFailedException ex = async
- ? await _pipeline.Diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false)
- : _pipeline.Diagnostics.CreateRequestFailedException(response);
-
- return OperationState.Failure(response, ex);
+ return OperationState.Failure(response, new RequestFailedException(response));
}
}
}
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Keys/src/RecoverDeletedKeyOperation.cs b/sdk/keyvault/Azure.Security.KeyVault.Keys/src/RecoverDeletedKeyOperation.cs
index 71fd05e63e144..3614f8a4a9b3e 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Keys/src/RecoverDeletedKeyOperation.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Keys/src/RecoverDeletedKeyOperation.cs
@@ -101,11 +101,7 @@ async ValueTask IOperation.UpdateStateAsync(bool async, Cancella
return OperationState.Pending(response);
default:
- RequestFailedException ex = async
- ? await _pipeline.Diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false)
- : _pipeline.Diagnostics.CreateRequestFailedException(response);
-
- return OperationState.Failure(response, ex);
+ return OperationState.Failure(response, new RequestFailedException(response));
}
}
}
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Secrets/src/DeleteSecretOperation.cs b/sdk/keyvault/Azure.Security.KeyVault.Secrets/src/DeleteSecretOperation.cs
index fb4be907d6ed4..79258ddc9d436 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Secrets/src/DeleteSecretOperation.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Secrets/src/DeleteSecretOperation.cs
@@ -107,11 +107,7 @@ async ValueTask IOperation.UpdateStateAsync(bool async, Cancella
return OperationState.Pending(response);
default:
- RequestFailedException ex = async
- ? await _pipeline.Diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false)
- : _pipeline.Diagnostics.CreateRequestFailedException(response);
-
- return OperationState.Failure(response, ex);
+ return OperationState.Failure(response, new RequestFailedException(response));
}
}
}
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Secrets/src/RecoverDeletedSecretOperation.cs b/sdk/keyvault/Azure.Security.KeyVault.Secrets/src/RecoverDeletedSecretOperation.cs
index bbae1598c216a..bdfc212ba0001 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Secrets/src/RecoverDeletedSecretOperation.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Secrets/src/RecoverDeletedSecretOperation.cs
@@ -97,11 +97,7 @@ async ValueTask IOperation.UpdateStateAsync(bool async, Cancella
return OperationState.Pending(response);
default:
- RequestFailedException ex = async
- ? await _pipeline.Diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false)
- : _pipeline.Diagnostics.CreateRequestFailedException(response);
-
- return OperationState.Failure(response, ex);
+ return OperationState.Failure(response, new RequestFailedException(response));
}
}
}
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Shared/src/KeyVaultPipeline.cs b/sdk/keyvault/Azure.Security.KeyVault.Shared/src/KeyVaultPipeline.cs
index 24eb3e889b120..cbec6199ee5f2 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Shared/src/KeyVaultPipeline.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Shared/src/KeyVaultPipeline.cs
@@ -263,7 +263,7 @@ private async Task SendRequestAsync(Request request, CancellationToken
case 204:
return response;
default:
- throw await Diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false);
+ throw new RequestFailedException(response);
}
}
private Response SendRequest(Request request, CancellationToken cancellationToken)
@@ -278,7 +278,7 @@ private Response SendRequest(Request request, CancellationToken cancellationToke
case 204:
return response;
default:
- throw Diagnostics.CreateRequestFailedException(response);
+ throw new RequestFailedException(response);
}
}
}
From 833c8a59b183c7e2c249e767ef5c1b5de5df629b Mon Sep 17 00:00:00 2001
From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Date: Mon, 1 May 2023 15:41:21 -0700
Subject: [PATCH 09/16] Update more libraries
---
.../src/Azure.Data.AppConfiguration.csproj | 3 +
.../src/ConfigurationClient.cs | 32 ++++----
.../src/CallRecording.cs | 4 +-
.../src/Downloader/ContentDownloader.cs | 4 +-
.../src/CallRecording.cs | 4 +-
.../src/Downloader/ContentDownloader.cs | 4 +-
.../src/ChatThreadClient.cs | 4 +-
.../Generated/SipRoutingRestClient.cs | 4 +-
.../src/SipRouting/SipRoutingRestClient.cs | 4 +-
.../Azure.Security.ConfidentialLedger.csproj | 3 +
.../src/PostLedgerEntryOperation.cs | 4 +-
.../Pipeline/RequestFailedDetailsParser.cs | 2 +-
.../Azure.Core/src/RequestFailedException.cs | 38 ++++++++--
.../tests/FailedResponseExceptionTests.cs | 1 +
.../Customized/DigitalTwinModelsRestClient.cs | 8 +-
.../src/Customized/DigitalTwinsRestClient.cs | 36 ++++-----
.../src/Customized/QueryRestClient.cs | 4 +-
.../src/EventGridPublisherClient.cs | 16 +---
.../Azure.AI.FormRecognizer.sln | 6 ++
.../src/AnalyzeDocumentOperation.cs | 4 +-
.../src/Azure.AI.FormRecognizer.csproj | 3 +
.../src/BuildDocumentClassifierOperation.cs | 4 +-
.../src/BuildDocumentModelOperation.cs | 4 +-
.../src/ClassifyDocumentOperation.cs | 4 +-
.../src/ComposeDocumentModelOperation.cs | 4 +-
.../src/CopyDocumentModelToOperation.cs | 4 +-
.../RecognizeBusinessCardsOperation.cs | 4 +-
.../RecognizeContentOperation.cs | 4 +-
.../RecognizeCustomFormsOperation.cs | 4 +-
.../RecognizeIdentityDocumentsOperation.cs | 4 +-
.../RecognizeInvoicesOperation.cs | 4 +-
.../RecognizeReceiptsOperation.cs | 4 +-
.../FormTrainingClient/CopyModelOperation.cs | 4 +-
.../CreateCustomFormModelOperation.cs | 10 +--
.../src/Internal/ClientCommon.cs | 12 +--
sdk/identity/Azure.Identity.sln | 6 ++
.../Azure.Identity/src/Azure.Identity.csproj | 5 +-
.../src/ImdsManagedIdentitySource.cs | 2 +-
.../src/Customized/JobsRestClient.cs | 4 +-
.../src/Fetchers/HttpModelFetcher.cs | 4 +-
.../src/LogsQueryClient.cs | 18 +----
.../tests/LogSenderClient.cs | 2 +-
.../tests/MetricsSenderClient.cs | 2 +-
.../src/Generated/EvaluationsRestClient.cs | 16 ++--
.../src/Generated/EventsRestClient.cs | 8 +-
.../src/Generated/LogRestClient.cs | 8 +-
.../src/Generated/ModelRestClient.cs | 16 ++--
.../Generated/MultiSlotEventsRestClient.cs | 8 +-
.../src/Generated/MultiSlotRestClient.cs | 4 +-
.../src/Generated/PolicyRestClient.cs | 12 +--
.../src/Generated/RankRestClient.cs | 4 +-
.../ServiceConfigurationRestClient.cs | 12 +--
.../Administration/HttpRequestAndResponse.cs | 6 +-
.../NamespacePropertiesExtensions.cs | 4 +-
.../QueuePropertiesExtensions.cs | 6 +-
.../QueueRuntimePropertiesExtensions.cs | 6 +-
.../Rules/RuleDescriptionExtensions.cs | 4 +-
.../SubscriptionPropertiesExtensions.cs | 6 +-
...SubscriptionRuntimePropertiesExtensions.cs | 12 +--
.../TopicPropertiesExtensions.cs | 6 +-
.../TopicRuntimePropertiesExtensions.cs | 6 +-
.../src/Azure.Storage.Blobs.Batch.csproj | 3 +
.../src/BatchErrors.cs | 2 +-
.../src/BlobBatch.cs | 8 +-
.../src/BlobBatchClient.cs | 4 +-
.../src/DelayedResponse.cs | 8 +-
.../tests/DelayedResponseTests.cs | 4 +-
.../src/ErrorExtensions.cs | 68 -----------------
.../Azure.Data.Tables/src/TableClient.cs | 2 +-
.../Azure.Data.Tables/src/TableRestClient.cs | 2 +-
.../Generated/ApplicationsRestOperations.cs | 64 ++++++++--------
.../DeletedApplicationsRestOperations.cs | 20 ++---
.../src/Generated/DomainsRestOperations.cs | 8 +-
.../src/Generated/GroupsRestOperations.cs | 68 ++++++++---------
.../OAuth2PermissionGrantRestOperations.cs | 20 ++---
.../src/Generated/ObjectsRestOperations.cs | 12 +--
.../ServicePrincipalsRestOperations.cs | 76 +++++++++----------
.../Generated/SignedInUserRestOperations.cs | 16 ++--
.../src/Generated/UsersRestOperations.cs | 32 ++++----
.../src/DocumentTranslationOperation.cs | 9 +--
80 files changed, 396 insertions(+), 475 deletions(-)
delete mode 100644 sdk/storage/Azure.Storage.Files.DataLake/src/ErrorExtensions.cs
diff --git a/sdk/appconfiguration/Azure.Data.AppConfiguration/src/Azure.Data.AppConfiguration.csproj b/sdk/appconfiguration/Azure.Data.AppConfiguration/src/Azure.Data.AppConfiguration.csproj
index 3c8de240007a6..3dd52bb945233 100644
--- a/sdk/appconfiguration/Azure.Data.AppConfiguration/src/Azure.Data.AppConfiguration.csproj
+++ b/sdk/appconfiguration/Azure.Data.AppConfiguration/src/Azure.Data.AppConfiguration.csproj
@@ -14,6 +14,9 @@
+
+
+
diff --git a/sdk/appconfiguration/Azure.Data.AppConfiguration/src/ConfigurationClient.cs b/sdk/appconfiguration/Azure.Data.AppConfiguration/src/ConfigurationClient.cs
index 5f7527cc6f942..e8380a25d6142 100644
--- a/sdk/appconfiguration/Azure.Data.AppConfiguration/src/ConfigurationClient.cs
+++ b/sdk/appconfiguration/Azure.Data.AppConfiguration/src/ConfigurationClient.cs
@@ -175,9 +175,9 @@ public virtual async Task> AddConfigurationSettin
case 201:
return await CreateResponseAsync(response, cancellationToken).ConfigureAwait(false);
case 412:
- throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(response, new ResponseError(null, "Setting was already present.")).ConfigureAwait(false);
+ throw new RequestFailedException(response, null, new ResponseError(null, "Setting was already present."));
default:
- throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false);
+ throw new RequestFailedException(response);
}
}
catch (Exception e)
@@ -214,9 +214,9 @@ public virtual Response AddConfigurationSetting(Configurat
case 201:
return CreateResponse(response);
case 412:
- throw ClientDiagnostics.CreateRequestFailedException(response, new ResponseError(null, "Setting was already present."));
+ throw new RequestFailedException(response, null, new ResponseError(null, "Setting was already present."));
default:
- throw ClientDiagnostics.CreateRequestFailedException(response);
+ throw new RequestFailedException(response);
}
}
catch (Exception e)
@@ -283,10 +283,10 @@ public virtual async Task> SetConfigurationSettin
return response.Status switch
{
200 => await CreateResponseAsync(response, cancellationToken).ConfigureAwait(false),
- 409 => throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(response, new ResponseError(null, "The setting is read only")).ConfigureAwait(false),
+ 409 => throw new RequestFailedException(response, null, new ResponseError(null, "The setting is read only")),
// Throws on 412 if resource was modified.
- _ => throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false),
+ _ => throw new RequestFailedException(response),
};
}
catch (Exception e)
@@ -326,10 +326,10 @@ public virtual Response SetConfigurationSetting(Configurat
return response.Status switch
{
200 => CreateResponse(response),
- 409 => throw ClientDiagnostics.CreateRequestFailedException(response, new ResponseError(null, "The setting is read only")),
+ 409 => throw new RequestFailedException(response, null, new ResponseError(null, "The setting is read only")),
// Throws on 412 if resource was modified.
- _ => throw ClientDiagnostics.CreateRequestFailedException(response),
+ _ => throw new RequestFailedException(response),
};
}
catch (Exception e)
@@ -415,10 +415,10 @@ private async Task DeleteConfigurationSettingAsync(string key, string
{
200 => response,
204 => response,
- 409 => throw ClientDiagnostics.CreateRequestFailedException(response, new ResponseError(null, "The setting is read only")),
+ 409 => throw new RequestFailedException(response, null, new ResponseError(null, "The setting is read only")),
// Throws on 412 if resource was modified.
- _ => throw ClientDiagnostics.CreateRequestFailedException(response)
+ _ => throw new RequestFailedException(response)
};
}
catch (Exception e)
@@ -444,10 +444,10 @@ private Response DeleteConfigurationSetting(string key, string label, MatchCondi
{
200 => response,
204 => response,
- 409 => throw ClientDiagnostics.CreateRequestFailedException(response, new ResponseError(null, "The setting is read only.")),
+ 409 => throw new RequestFailedException(response, null, new ResponseError(null, "The setting is read only.")),
// Throws on 412 if resource was modified.
- _ => throw ClientDiagnostics.CreateRequestFailedException(response)
+ _ => throw new RequestFailedException(response)
};
}
catch (Exception e)
@@ -569,7 +569,7 @@ internal virtual async Task> GetConfigurationSett
{
200 => await CreateResponseAsync(response, cancellationToken).ConfigureAwait(false),
304 => CreateResourceModifiedResponse(response),
- _ => throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false),
+ _ => throw new RequestFailedException(response),
};
}
catch (Exception e)
@@ -605,7 +605,7 @@ internal virtual Response GetConfigurationSetting(string k
{
200 => CreateResponse(response),
304 => CreateResourceModifiedResponse(response),
- _ => throw ClientDiagnostics.CreateRequestFailedException(response),
+ _ => throw new RequestFailedException(response),
};
}
catch (Exception e)
@@ -1370,9 +1370,7 @@ private async ValueTask> SetReadOnlyAsync(string
200 => async
? await CreateResponseAsync(response, cancellationToken).ConfigureAwait(false)
: CreateResponse(response),
- _ => throw (async
- ? await ClientDiagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false)
- : ClientDiagnostics.CreateRequestFailedException(response))
+ _ => throw new RequestFailedException(response)
};
}
catch (Exception e)
diff --git a/sdk/communication/Azure.Communication.CallAutomation/src/CallRecording.cs b/sdk/communication/Azure.Communication.CallAutomation/src/CallRecording.cs
index e7d1697be5226..14bed08c96c4f 100644
--- a/sdk/communication/Azure.Communication.CallAutomation/src/CallRecording.cs
+++ b/sdk/communication/Azure.Communication.CallAutomation/src/CallRecording.cs
@@ -551,7 +551,7 @@ public virtual Response DeleteRecording(Uri recordingLocation, CancellationToken
case 200:
return message.Response;
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
catch (Exception ex)
@@ -594,7 +594,7 @@ public virtual async Task DeleteRecordingAsync(Uri recordingLocation,
case 200:
return message.Response;
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
catch (Exception ex)
diff --git a/sdk/communication/Azure.Communication.CallAutomation/src/Downloader/ContentDownloader.cs b/sdk/communication/Azure.Communication.CallAutomation/src/Downloader/ContentDownloader.cs
index 3acfb9bdd8361..d8d5012e39c08 100644
--- a/sdk/communication/Azure.Communication.CallAutomation/src/Downloader/ContentDownloader.cs
+++ b/sdk/communication/Azure.Communication.CallAutomation/src/Downloader/ContentDownloader.cs
@@ -84,7 +84,7 @@ private async Task> StartDownloadAsync(Uri sourceEndpoint, Http
return Response.FromValue(value, message.Response);
}
default:
- throw await _client._clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -113,7 +113,7 @@ private Response StartDownload(Uri sourceEndpoint, HttpRange range = def
return Response.FromValue(value, message.Response);
}
default:
- throw _client._clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
diff --git a/sdk/communication/Azure.Communication.CallingServer/src/CallRecording.cs b/sdk/communication/Azure.Communication.CallingServer/src/CallRecording.cs
index 9aaef93b9d373..60a7c28b426ad 100644
--- a/sdk/communication/Azure.Communication.CallingServer/src/CallRecording.cs
+++ b/sdk/communication/Azure.Communication.CallingServer/src/CallRecording.cs
@@ -543,7 +543,7 @@ public virtual Response DeleteRecording(Uri recordingLocation, CancellationToken
case 200:
return message.Response;
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
catch (Exception ex)
@@ -586,7 +586,7 @@ public virtual async Task DeleteRecordingAsync(Uri recordingLocation,
case 200:
return message.Response;
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
catch (Exception ex)
diff --git a/sdk/communication/Azure.Communication.CallingServer/src/Downloader/ContentDownloader.cs b/sdk/communication/Azure.Communication.CallingServer/src/Downloader/ContentDownloader.cs
index 5ca599375d6c1..864233c9d5400 100644
--- a/sdk/communication/Azure.Communication.CallingServer/src/Downloader/ContentDownloader.cs
+++ b/sdk/communication/Azure.Communication.CallingServer/src/Downloader/ContentDownloader.cs
@@ -84,7 +84,7 @@ private async Task> StartDownloadAsync(Uri sourceEndpoint, Http
return Response.FromValue(value, message.Response);
}
default:
- throw await _client._clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -113,7 +113,7 @@ private Response StartDownload(Uri sourceEndpoint, HttpRange range = def
return Response.FromValue(value, message.Response);
}
default:
- throw _client._clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
diff --git a/sdk/communication/Azure.Communication.Chat/src/ChatThreadClient.cs b/sdk/communication/Azure.Communication.Chat/src/ChatThreadClient.cs
index a4cfc05bcd3ee..970cb47630f2e 100644
--- a/sdk/communication/Azure.Communication.Chat/src/ChatThreadClient.cs
+++ b/sdk/communication/Azure.Communication.Chat/src/ChatThreadClient.cs
@@ -428,7 +428,7 @@ public virtual async Task AddParticipantAsync(ChatParticipant particip
Response addChatParticipantsResult = await _chatThreadRestClient.AddChatParticipantsAsync(Id, new[] { participant.ToChatParticipantInternal() }, cancellationToken).ConfigureAwait(false);
if (addChatParticipantsResult.Value.InvalidParticipants.Count > 0)
{
- throw _clientDiagnostics.CreateRequestFailedException(addChatParticipantsResult.GetRawResponse());
+ throw new RequestFailedException(addChatParticipantsResult.GetRawResponse());
}
return addChatParticipantsResult.GetRawResponse();
}
@@ -452,7 +452,7 @@ public virtual Response AddParticipant(ChatParticipant participant, Cancellation
Response addChatParticipantsResult = _chatThreadRestClient.AddChatParticipants(Id, new[] { participant.ToChatParticipantInternal() }, cancellationToken);
if (addChatParticipantsResult.Value.InvalidParticipants.Count > 0)
{
- throw _clientDiagnostics.CreateRequestFailedException(addChatParticipantsResult.GetRawResponse());
+ throw new RequestFailedException(addChatParticipantsResult.GetRawResponse());
}
return addChatParticipantsResult.GetRawResponse();
}
diff --git a/sdk/communication/Azure.Communication.PhoneNumbers/src/SipRouting/Generated/SipRoutingRestClient.cs b/sdk/communication/Azure.Communication.PhoneNumbers/src/SipRouting/Generated/SipRoutingRestClient.cs
index 89bc4570e109b..95285885e183d 100644
--- a/sdk/communication/Azure.Communication.PhoneNumbers/src/SipRouting/Generated/SipRoutingRestClient.cs
+++ b/sdk/communication/Azure.Communication.PhoneNumbers/src/SipRouting/Generated/SipRoutingRestClient.cs
@@ -68,7 +68,7 @@ public async Task> GetSipConfigurationAsync(Cancellat
return Response.FromValue(value, message.Response);
}
default:
- throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -88,7 +88,7 @@ public Response GetSipConfiguration(CancellationToken cancella
return Response.FromValue(value, message.Response);
}
default:
- throw ClientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
}
diff --git a/sdk/communication/Azure.Communication.PhoneNumbers/src/SipRouting/SipRoutingRestClient.cs b/sdk/communication/Azure.Communication.PhoneNumbers/src/SipRouting/SipRoutingRestClient.cs
index 66f737fab4d22..685aadbfa8d89 100644
--- a/sdk/communication/Azure.Communication.PhoneNumbers/src/SipRouting/SipRoutingRestClient.cs
+++ b/sdk/communication/Azure.Communication.PhoneNumbers/src/SipRouting/SipRoutingRestClient.cs
@@ -54,7 +54,7 @@ public async Task UpdateAsync(SipConfiguration body = null, Cancellati
return mappedResponse;
}
default:
- throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -79,7 +79,7 @@ public Response Update(SipConfiguration body = null, CancellationToken cancellat
return mappedResponse;
}
default:
- throw ClientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
}
diff --git a/sdk/confidentialledger/Azure.Security.ConfidentialLedger/src/Azure.Security.ConfidentialLedger.csproj b/sdk/confidentialledger/Azure.Security.ConfidentialLedger/src/Azure.Security.ConfidentialLedger.csproj
index 033bc30cee715..4352f475967f7 100644
--- a/sdk/confidentialledger/Azure.Security.ConfidentialLedger/src/Azure.Security.ConfidentialLedger.csproj
+++ b/sdk/confidentialledger/Azure.Security.ConfidentialLedger/src/Azure.Security.ConfidentialLedger.csproj
@@ -16,6 +16,9 @@
+
+
+
diff --git a/sdk/confidentialledger/Azure.Security.ConfidentialLedger/src/PostLedgerEntryOperation.cs b/sdk/confidentialledger/Azure.Security.ConfidentialLedger/src/PostLedgerEntryOperation.cs
index e8b73356dbd8a..75d0381ee8778 100644
--- a/sdk/confidentialledger/Azure.Security.ConfidentialLedger/src/PostLedgerEntryOperation.cs
+++ b/sdk/confidentialledger/Azure.Security.ConfidentialLedger/src/PostLedgerEntryOperation.cs
@@ -64,9 +64,7 @@ async ValueTask IOperation.UpdateStateAsync(bool async, Cancella
if (statusResponse.Status != (int)HttpStatusCode.OK)
{
var error = new ResponseError(null, exceptionMessage);
- var ex = async
- ? await _client.ClientDiagnostics.CreateRequestFailedExceptionAsync(statusResponse, error).ConfigureAwait(false)
- : _client.ClientDiagnostics.CreateRequestFailedException(statusResponse, error);
+ var ex = new RequestFailedException(statusResponse, null, error);
return OperationState.Failure(statusResponse, new RequestFailedException(exceptionMessage, ex));
}
diff --git a/sdk/core/Azure.Core/src/Pipeline/RequestFailedDetailsParser.cs b/sdk/core/Azure.Core/src/Pipeline/RequestFailedDetailsParser.cs
index 46c0ddb4ddefe..5779d8da6a02c 100644
--- a/sdk/core/Azure.Core/src/Pipeline/RequestFailedDetailsParser.cs
+++ b/sdk/core/Azure.Core/src/Pipeline/RequestFailedDetailsParser.cs
@@ -14,7 +14,7 @@ public abstract class RequestFailedDetailsParser
///
/// Parses the error details from the provided .
///
- /// The to parse.
+ /// The to parse. The will already be buffered.
/// The describing the parsed error details.
/// Data to be applied to the property.
/// true if successful, otherwise false.
diff --git a/sdk/core/Azure.Core/src/RequestFailedException.cs b/sdk/core/Azure.Core/src/RequestFailedException.cs
index bc293de3c27f2..986afe5ac16b7 100644
--- a/sdk/core/Azure.Core/src/RequestFailedException.cs
+++ b/sdk/core/Azure.Core/src/RequestFailedException.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Runtime.Serialization;
@@ -38,6 +39,7 @@ public class RequestFailedException : Exception, ISerializable
/// Initializes a new instance of the class with a specified error message.
/// The message that describes the error.
+ [EditorBrowsable(EditorBrowsableState.Never)]
public RequestFailedException(string message) : this(0, message)
{
}
@@ -45,6 +47,7 @@ public RequestFailedException(string message) : this(0, message)
/// Initializes a new instance of the class with a specified error message, HTTP status code and a reference to the inner exception that is the cause of this exception.
/// The error message that explains the reason for the exception.
/// The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.
+ [EditorBrowsable(EditorBrowsableState.Never)]
public RequestFailedException(string message, Exception? innerException) : this(0, message, innerException)
{
}
@@ -52,6 +55,7 @@ public RequestFailedException(string message, Exception? innerException) : this(
/// Initializes a new instance of the class with a specified error message and HTTP status code.
/// The HTTP status code, or 0 if not available.
/// The message that describes the error.
+ [EditorBrowsable(EditorBrowsableState.Never)]
public RequestFailedException(int status, string message)
: this(status, message, null)
{
@@ -61,6 +65,7 @@ public RequestFailedException(int status, string message)
/// The HTTP status code, or 0 if not available.
/// The error message that explains the reason for the exception.
/// The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.
+ [EditorBrowsable(EditorBrowsableState.Never)]
public RequestFailedException(int status, string message, Exception? innerException)
: this(status, message, null, innerException)
{
@@ -71,6 +76,7 @@ public RequestFailedException(int status, string message, Exception? innerExcept
/// The error message that explains the reason for the exception.
/// The service specific error code.
/// The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.
+ [EditorBrowsable(EditorBrowsableState.Never)]
public RequestFailedException(int status, string message, string? errorCode, Exception? innerException)
: base(message, innerException)
{
@@ -108,7 +114,18 @@ public RequestFailedException(Response response)
/// The response to obtain error details from.
/// An inner exception to associate with the new .
public RequestFailedException(Response response, Exception? innerException)
- : this(response.Status, GetRequestFailedExceptionContent(response), innerException)
+ : this(response, innerException, null)
+ {
+ }
+
+ /// Initializes a new instance of the class
+ /// with an error message, HTTP status code, error code obtained from the specified response.
+ /// The response to obtain error details from.
+ /// An inner exception to associate with the new .
+ /// The error information to use when constructing the exception message. If null, this will be parsed from the Response body.
+ /// Additional information to include in the exception message. This will also be stored in the property.
+ public RequestFailedException(Response response, Exception? innerException, ResponseError? error, IDictionary? additionalInfo = null)
+ : this(response.Status, GetRequestFailedExceptionContent(response, error, additionalInfo), innerException)
{
_response = response;
}
@@ -137,11 +154,20 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont
///
public Response? GetRawResponse() => _response;
- internal static (string FormattedError, string? ErrorCode, IDictionary? Data) GetRequestFailedExceptionContent(Response response)
+ internal static (string FormattedError, string? ErrorCode, IDictionary? Data) GetRequestFailedExceptionContent(Response response, ResponseError? error, IDictionary? additionalInfo)
{
BufferResponseIfNeeded(response);
- bool parseSuccess = response.RequestFailedDetailsParser == null ? TryExtractErrorContent(response, out ResponseError? error, out IDictionary? data) : response.RequestFailedDetailsParser.TryParse(response, out error, out data);
+ // only attempt to parse the error and additional info if not already provided.
+ if (error == null && additionalInfo == null)
+ {
+ bool parseSuccess = response.RequestFailedDetailsParser == null ? TryExtractErrorContent(response, out error, out additionalInfo) : response.RequestFailedDetailsParser.TryParse(response, out error, out additionalInfo);
+ if (!parseSuccess)
+ {
+ error = null;
+ additionalInfo = null;
+ }
+ }
StringBuilder messageBuilder = new();
messageBuilder
@@ -167,12 +193,12 @@ internal static (string FormattedError, string? ErrorCode, IDictionary 0)
+ if (additionalInfo is { Count: > 0 })
{
messageBuilder
.AppendLine()
.AppendLine("Additional Information:");
- foreach (KeyValuePair info in data)
+ foreach (KeyValuePair info in additionalInfo)
{
messageBuilder
.Append(info.Key)
@@ -201,7 +227,7 @@ internal static (string FormattedError, string? ErrorCode, IDictionary>> AddAsync(
return Response.FromValue(value, message.Response);
}
default:
- throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -70,7 +70,7 @@ internal Response> Add(
return Response.FromValue(value, message.Response);
}
default:
- throw ClientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -96,7 +96,7 @@ internal async Task UpdateAsync(
return message.Response.Status switch
{
204 => message.Response,
- _ => throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false),
+ _ => throw new RequestFailedException(message.Response),
};
}
@@ -122,7 +122,7 @@ internal Response Update(
return message.Response.Status switch
{
204 => message.Response,
- _ => throw ClientDiagnostics.CreateRequestFailedException(message.Response),
+ _ => throw new RequestFailedException(message.Response),
};
}
diff --git a/sdk/digitaltwins/Azure.DigitalTwins.Core/src/Customized/DigitalTwinsRestClient.cs b/sdk/digitaltwins/Azure.DigitalTwins.Core/src/Customized/DigitalTwinsRestClient.cs
index 4ecb1288c11ec..06d7547059c5c 100644
--- a/sdk/digitaltwins/Azure.DigitalTwins.Core/src/Customized/DigitalTwinsRestClient.cs
+++ b/sdk/digitaltwins/Azure.DigitalTwins.Core/src/Customized/DigitalTwinsRestClient.cs
@@ -77,7 +77,7 @@ internal async Task> AddAsync(
return Response.FromValue(null, message.Response);
default:
- throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -109,7 +109,7 @@ internal Response Add(
return Response.FromValue(null, message.Response);
default:
- throw ClientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -137,7 +137,7 @@ internal async Task UpdateAsync(
return message.Response;
default:
- throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -165,7 +165,7 @@ internal Response Update(
return message.Response;
default:
- throw ClientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -199,7 +199,7 @@ internal async Task> AddRelationshipAsync(
return Response.FromValue(value, message.Response);
}
default:
- throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -233,7 +233,7 @@ public Response AddRelationship(
return Response.FromValue(value, message.Response);
}
default:
- throw ClientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -258,7 +258,7 @@ internal async Task UpdateRelationshipAsync(
return message.Response.Status switch
{
204 => message.Response,
- _ => throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false),
+ _ => throw new RequestFailedException(message.Response),
};
}
@@ -283,7 +283,7 @@ internal Response UpdateRelationship(
return message.Response.Status switch
{
204 => message.Response,
- _ => throw ClientDiagnostics.CreateRequestFailedException(message.Response),
+ _ => throw new RequestFailedException(message.Response),
};
}
@@ -312,7 +312,7 @@ internal async Task UpdateComponentAsync(
return message.Response;
default:
- throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -341,7 +341,7 @@ internal Response UpdateComponent(
return message.Response;
default:
- throw ClientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -373,7 +373,7 @@ internal async Task SendTelemetryAsync(
return message.Response;
default:
- throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -405,7 +405,7 @@ internal Response SendTelemetry(
return message.Response;
default:
- throw ClientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -442,7 +442,7 @@ internal async Task SendComponentTelemetryAsync(
return message.Response;
default:
- throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -479,7 +479,7 @@ internal Response SendComponentTelemetry(
return message.Response;
default:
- throw ClientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -511,7 +511,7 @@ internal async Task>> ListRelationshipsAsync<
return Response.FromValue(value, message.Response);
}
default:
- throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -549,7 +549,7 @@ internal async Task>> ListRelationshipsNextPa
return Response.FromValue(value, message.Response);
}
default:
- throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -581,7 +581,7 @@ internal Response> ListRelationships(
return Response.FromValue(value, message.Response);
}
default:
- throw ClientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -619,7 +619,7 @@ internal Response> ListRelationshipsNextPage(
return Response.FromValue(value, message.Response);
}
default:
- throw ClientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
diff --git a/sdk/digitaltwins/Azure.DigitalTwins.Core/src/Customized/QueryRestClient.cs b/sdk/digitaltwins/Azure.DigitalTwins.Core/src/Customized/QueryRestClient.cs
index 9602697e14b26..96517d9b7f785 100644
--- a/sdk/digitaltwins/Azure.DigitalTwins.Core/src/Customized/QueryRestClient.cs
+++ b/sdk/digitaltwins/Azure.DigitalTwins.Core/src/Customized/QueryRestClient.cs
@@ -40,7 +40,7 @@ internal async Task, QueryQueryTwinsHeaders>>
return ResponseWithHeaders.FromValue(value, headers, message.Response);
}
default:
- throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -72,7 +72,7 @@ internal ResponseWithHeaders, QueryQueryTwinsHeaders> QueryTwins<
return ResponseWithHeaders.FromValue(value, headers, message.Response);
}
default:
- throw ClientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/src/EventGridPublisherClient.cs b/sdk/eventgrid/Azure.Messaging.EventGrid/src/EventGridPublisherClient.cs
index 023d0f67b50fb..57f581bbc528d 100644
--- a/sdk/eventgrid/Azure.Messaging.EventGrid/src/EventGridPublisherClient.cs
+++ b/sdk/eventgrid/Azure.Messaging.EventGrid/src/EventGridPublisherClient.cs
@@ -121,9 +121,7 @@ private async Task SendCloudNativeCloudEventsInternalAsync(ReadOnlyMem
return message.Response.Status switch
{
200 => message.Response,
- _ => async ?
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false) :
- throw _clientDiagnostics.CreateRequestFailedException(message.Response)
+ _ => throw new RequestFailedException(message.Response)
};
}
catch (Exception e)
@@ -190,9 +188,7 @@ private async Task SendEventsInternal(IEnumerable even
return message.Response.Status switch
{
200 => message.Response,
- _ => async ?
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false) :
- throw _clientDiagnostics.CreateRequestFailedException(message.Response)
+ _ => throw new RequestFailedException(message.Response)
};
}
catch (Exception e)
@@ -294,9 +290,7 @@ private async Task SendCloudEventsInternal(IEnumerable eve
return message.Response.Status switch
{
200 => message.Response,
- _ => async ?
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false) :
- throw _clientDiagnostics.CreateRequestFailedException(message.Response)
+ _ => throw new RequestFailedException(message.Response)
};
}
catch (Exception e)
@@ -364,9 +358,7 @@ private async Task PublishCustomEventsInternal(IEnumerable
return message.Response.Status switch
{
200 => message.Response,
- _ => async ?
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false) :
- throw _clientDiagnostics.CreateRequestFailedException(message.Response)
+ _ => throw new RequestFailedException(message.Response)
};
}
catch (Exception e)
diff --git a/sdk/formrecognizer/Azure.AI.FormRecognizer/Azure.AI.FormRecognizer.sln b/sdk/formrecognizer/Azure.AI.FormRecognizer/Azure.AI.FormRecognizer.sln
index f60d4ed4b326c..1b09b9e198fec 100644
--- a/sdk/formrecognizer/Azure.AI.FormRecognizer/Azure.AI.FormRecognizer.sln
+++ b/sdk/formrecognizer/Azure.AI.FormRecognizer/Azure.AI.FormRecognizer.sln
@@ -13,6 +13,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Test.Perf", "..\..\..
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.AI.FormRecognizer.Perf", "perf\Azure.AI.FormRecognizer.Perf\Azure.AI.FormRecognizer.Perf.csproj", "{E11C4DF2-C78A-4EE3-B3FC-BE4F7C7A80F1}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Core", "..\..\core\Azure.Core\src\Azure.Core.csproj", "{835A88E0-375D-4403-B2FF-206187559302}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -43,6 +45,10 @@ Global
{6C5E5550-A9AE-4B52-84E5-32E035AC4D40}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6C5E5550-A9AE-4B52-84E5-32E035AC4D40}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6C5E5550-A9AE-4B52-84E5-32E035AC4D40}.Release|Any CPU.Build.0 = Release|Any CPU
+ {835A88E0-375D-4403-B2FF-206187559302}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {835A88E0-375D-4403-B2FF-206187559302}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {835A88E0-375D-4403-B2FF-206187559302}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {835A88E0-375D-4403-B2FF-206187559302}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/AnalyzeDocumentOperation.cs b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/AnalyzeDocumentOperation.cs
index 811bac209741b..4edd2e9ca636d 100644
--- a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/AnalyzeDocumentOperation.cs
+++ b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/AnalyzeDocumentOperation.cs
@@ -197,9 +197,7 @@ async ValueTask> IOperation.UpdateS
}
else if (status == AnalyzeResultOperationStatus.Failed)
{
- RequestFailedException requestFailedException = await ClientCommon
- .CreateExceptionForFailedOperationAsync(async, _diagnostics, rawResponse, response.Value.Error)
- .ConfigureAwait(false);
+ RequestFailedException requestFailedException = ClientCommon.CreateExceptionForFailedOperation(rawResponse, response.Value.Error);
return OperationState.Failure(rawResponse, requestFailedException);
}
diff --git a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/Azure.AI.FormRecognizer.csproj b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/Azure.AI.FormRecognizer.csproj
index 74b0d3e038f98..5f9e372b94a11 100644
--- a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/Azure.AI.FormRecognizer.csproj
+++ b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/Azure.AI.FormRecognizer.csproj
@@ -12,6 +12,9 @@
+
+
+
diff --git a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/BuildDocumentClassifierOperation.cs b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/BuildDocumentClassifierOperation.cs
index 09994a0332007..b4ab1552cd077 100644
--- a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/BuildDocumentClassifierOperation.cs
+++ b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/BuildDocumentClassifierOperation.cs
@@ -182,9 +182,7 @@ async ValueTask> IOperation.Failure(rawResponse, requestFailedException);
}
diff --git a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/BuildDocumentModelOperation.cs b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/BuildDocumentModelOperation.cs
index 0a56afd8b2af1..fc64452bb4c09 100644
--- a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/BuildDocumentModelOperation.cs
+++ b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/BuildDocumentModelOperation.cs
@@ -182,9 +182,7 @@ async ValueTask> IOperation.Failure(rawResponse, requestFailedException);
}
diff --git a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/ClassifyDocumentOperation.cs b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/ClassifyDocumentOperation.cs
index acef99aee39dc..c62ab47990cb1 100644
--- a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/ClassifyDocumentOperation.cs
+++ b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/ClassifyDocumentOperation.cs
@@ -185,9 +185,7 @@ async ValueTask> IOperation.UpdateS
}
else if (status == AnalyzeResultOperationStatus.Failed)
{
- RequestFailedException requestFailedException = await ClientCommon
- .CreateExceptionForFailedOperationAsync(async, _diagnostics, rawResponse, response.Value.Error)
- .ConfigureAwait(false);
+ RequestFailedException requestFailedException = ClientCommon.CreateExceptionForFailedOperation(rawResponse, response.Value.Error);
return OperationState.Failure(rawResponse, requestFailedException);
}
diff --git a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/ComposeDocumentModelOperation.cs b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/ComposeDocumentModelOperation.cs
index 051a7fbf76c79..bbbc91b59d561 100644
--- a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/ComposeDocumentModelOperation.cs
+++ b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/ComposeDocumentModelOperation.cs
@@ -182,9 +182,7 @@ async ValueTask> IOperation.Failure(rawResponse, requestFailedException);
}
diff --git a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/CopyDocumentModelToOperation.cs b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/CopyDocumentModelToOperation.cs
index 8d02be5876eb5..99b5c296b7d52 100644
--- a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/CopyDocumentModelToOperation.cs
+++ b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/CopyDocumentModelToOperation.cs
@@ -187,9 +187,7 @@ async ValueTask> IOperation.Failure(rawResponse, requestFailedException);
}
diff --git a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/RecognizeBusinessCardsOperation.cs b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/RecognizeBusinessCardsOperation.cs
index 903a21a759cf2..f5dca714914ec 100644
--- a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/RecognizeBusinessCardsOperation.cs
+++ b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/RecognizeBusinessCardsOperation.cs
@@ -164,9 +164,7 @@ async ValueTask> IOperation.Failure(rawResponse, requestFailedException);
}
diff --git a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/RecognizeContentOperation.cs b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/RecognizeContentOperation.cs
index abc7ef2dc92b4..0a0ab301a0ad8 100644
--- a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/RecognizeContentOperation.cs
+++ b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/RecognizeContentOperation.cs
@@ -165,9 +165,7 @@ async ValueTask> IOperation.Failure(rawResponse, requestFailedException);
}
diff --git a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/RecognizeCustomFormsOperation.cs b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/RecognizeCustomFormsOperation.cs
index 39a5ca8a7ff29..5f1f2adbb37e7 100644
--- a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/RecognizeCustomFormsOperation.cs
+++ b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/RecognizeCustomFormsOperation.cs
@@ -198,9 +198,7 @@ async ValueTask> IOperation.Failure(rawResponse, requestFailedException);
}
diff --git a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/RecognizeIdentityDocumentsOperation.cs b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/RecognizeIdentityDocumentsOperation.cs
index f072490db91ca..ab8b2abd681fd 100644
--- a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/RecognizeIdentityDocumentsOperation.cs
+++ b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/RecognizeIdentityDocumentsOperation.cs
@@ -163,9 +163,7 @@ async ValueTask> IOperation.Failure(rawResponse, requestFailedException);
}
diff --git a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/RecognizeInvoicesOperation.cs b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/RecognizeInvoicesOperation.cs
index a3d46e8a1121e..e244ce294a0bd 100644
--- a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/RecognizeInvoicesOperation.cs
+++ b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/RecognizeInvoicesOperation.cs
@@ -164,9 +164,7 @@ async ValueTask> IOperation.Failure(rawResponse, requestFailedException);
}
diff --git a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/RecognizeReceiptsOperation.cs b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/RecognizeReceiptsOperation.cs
index 80bedebd64935..94e0813907ed8 100644
--- a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/RecognizeReceiptsOperation.cs
+++ b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/RecognizeReceiptsOperation.cs
@@ -163,9 +163,7 @@ async ValueTask> IOperation.Failure(rawResponse, requestFailedException);
}
diff --git a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormTrainingClient/CopyModelOperation.cs b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormTrainingClient/CopyModelOperation.cs
index dd7c656ddf4cb..2bf49ebfe64db 100644
--- a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormTrainingClient/CopyModelOperation.cs
+++ b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormTrainingClient/CopyModelOperation.cs
@@ -197,9 +197,7 @@ async ValueTask> IOperation.Failure(rawResponse, requestFailedException);
}
diff --git a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormTrainingClient/CreateCustomFormModelOperation.cs b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormTrainingClient/CreateCustomFormModelOperation.cs
index d5f49bd8b2318..4653a3ac9371c 100644
--- a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormTrainingClient/CreateCustomFormModelOperation.cs
+++ b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormTrainingClient/CreateCustomFormModelOperation.cs
@@ -165,12 +165,10 @@ async ValueTask> IOperation.Upd
}
else if (status == CustomFormModelStatus.Invalid)
{
- RequestFailedException requestFailedException = await ClientCommon.CreateExceptionForFailedOperationAsync(
- async,
- _diagnostics,
- rawResponse,
- response.Value.TrainResult.Errors,
- $"Invalid model created with ID {response.Value.ModelInfo.ModelId}").ConfigureAwait(false);
+ RequestFailedException requestFailedException = ClientCommon.CreateExceptionForFailedOperation(
+ rawResponse,
+ response.Value.TrainResult.Errors,
+ $"Invalid model created with ID {response.Value.ModelInfo.ModelId}");
return OperationState.Failure(rawResponse, requestFailedException);
}
diff --git a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/Internal/ClientCommon.cs b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/Internal/ClientCommon.cs
index 3287fe3ad7c41..e5eefbca3649c 100644
--- a/sdk/formrecognizer/Azure.AI.FormRecognizer/src/Internal/ClientCommon.cs
+++ b/sdk/formrecognizer/Azure.AI.FormRecognizer/src/Internal/ClientCommon.cs
@@ -49,7 +49,7 @@ public static string GetResponseHeader(ResponseHeaders responseHeaders, string h
}
}
- public static async ValueTask CreateExceptionForFailedOperationAsync(bool async, ClientDiagnostics diagnostics, Response response, IReadOnlyList errors, string errorMessage = default)
+ public static RequestFailedException CreateExceptionForFailedOperation(Response response, IReadOnlyList errors, string errorMessage = default)
{
string errorCode = default;
@@ -68,17 +68,13 @@ public static async ValueTask CreateExceptionForFailedOp
}
var responseError = new ResponseError(errorCode, errorMessage);
- return async
- ? await diagnostics.CreateRequestFailedExceptionAsync(response, responseError, errorInfo).ConfigureAwait(false)
- : diagnostics.CreateRequestFailedException(response, responseError, errorInfo);
+ return new RequestFailedException(response, null, responseError, errorInfo);
}
- public static async ValueTask CreateExceptionForFailedOperationAsync(bool async, ClientDiagnostics diagnostics, Response response, ResponseError error)
+ public static RequestFailedException CreateExceptionForFailedOperation(Response response, ResponseError error)
{
var additionalInfo = new Dictionary(1) { { "AdditionInformation", error.ToString() } };
- return async
- ? await diagnostics.CreateRequestFailedExceptionAsync(response, error, additionalInfo).ConfigureAwait(false)
- : diagnostics.CreateRequestFailedException(response, error, additionalInfo);
+ return new RequestFailedException(response, null, error, additionalInfo);
}
public static RecognizedFormCollection ConvertPrebuiltOutputToRecognizedForms(V2AnalyzeResult analyzeResult)
diff --git a/sdk/identity/Azure.Identity.sln b/sdk/identity/Azure.Identity.sln
index 1f6ea6a1991fd..e7addc6a1628e 100644
--- a/sdk/identity/Azure.Identity.sln
+++ b/sdk/identity/Azure.Identity.sln
@@ -17,6 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Identity.BrokeredAuth
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Identity.BrokeredAuthentication.Tests", "Azure.Identity.BrokeredAuthentication\tests\Azure.Identity.BrokeredAuthentication.Tests.csproj", "{5F72962A-E4A5-4DBD-BA00-AB5B7725CACA}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Core", "..\core\Azure.Core\src\Azure.Core.csproj", "{B8BF1ED4-DD68-4504-9060-008D1A980958}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -51,6 +53,10 @@ Global
{5F72962A-E4A5-4DBD-BA00-AB5B7725CACA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5F72962A-E4A5-4DBD-BA00-AB5B7725CACA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5F72962A-E4A5-4DBD-BA00-AB5B7725CACA}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B8BF1ED4-DD68-4504-9060-008D1A980958}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B8BF1ED4-DD68-4504-9060-008D1A980958}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B8BF1ED4-DD68-4504-9060-008D1A980958}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B8BF1ED4-DD68-4504-9060-008D1A980958}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/sdk/identity/Azure.Identity/src/Azure.Identity.csproj b/sdk/identity/Azure.Identity/src/Azure.Identity.csproj
index bc63692ed8f6b..6d3a20bdb1d12 100644
--- a/sdk/identity/Azure.Identity/src/Azure.Identity.csproj
+++ b/sdk/identity/Azure.Identity/src/Azure.Identity.csproj
@@ -11,7 +11,10 @@
true
-
+
+
+
+
diff --git a/sdk/identity/Azure.Identity/src/ImdsManagedIdentitySource.cs b/sdk/identity/Azure.Identity/src/ImdsManagedIdentitySource.cs
index fb54637b957d4..1291307c8b168 100644
--- a/sdk/identity/Azure.Identity/src/ImdsManagedIdentitySource.cs
+++ b/sdk/identity/Azure.Identity/src/ImdsManagedIdentitySource.cs
@@ -120,7 +120,7 @@ protected override async ValueTask HandleResponseAsync(bool async,
if (baseMessage != null)
{
- string message = await Pipeline.Diagnostics.CreateRequestFailedMessageAsync(response, new ResponseError(null, baseMessage), null, async).ConfigureAwait(false);
+ string message = new RequestFailedException(response, null, new ResponseError(null, baseMessage)).Message;
var errorContentMessage = await GetMessageFromResponse(response, async, cancellationToken).ConfigureAwait(false);
diff --git a/sdk/iot/Azure.IoT.Hub.Service/src/Customized/JobsRestClient.cs b/sdk/iot/Azure.IoT.Hub.Service/src/Customized/JobsRestClient.cs
index eee204efd35b6..27e21bdc6dd44 100644
--- a/sdk/iot/Azure.IoT.Hub.Service/src/Customized/JobsRestClient.cs
+++ b/sdk/iot/Azure.IoT.Hub.Service/src/Customized/JobsRestClient.cs
@@ -40,7 +40,7 @@ internal Response CancelImportExportJob(string id, CancellationToken can
return Response.FromValue(null, message.Response);
default:
- throw ClientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -73,7 +73,7 @@ internal async Task> CancelImportExportJobAsync(string id, Canc
return Response.FromValue(null, message.Response);
default:
- throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
diff --git a/sdk/modelsrepository/Azure.IoT.ModelsRepository/src/Fetchers/HttpModelFetcher.cs b/sdk/modelsrepository/Azure.IoT.ModelsRepository/src/Fetchers/HttpModelFetcher.cs
index bf388d2c427bc..f14f06ac7dfed 100644
--- a/sdk/modelsrepository/Azure.IoT.ModelsRepository/src/Fetchers/HttpModelFetcher.cs
+++ b/sdk/modelsrepository/Azure.IoT.ModelsRepository/src/Fetchers/HttpModelFetcher.cs
@@ -175,7 +175,7 @@ private string EvaluatePath(string path, CancellationToken cancellationToken = d
return GetContent(message.Response.ContentStream);
}
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
catch (Exception ex)
@@ -203,7 +203,7 @@ private async Task EvaluatePathAsync(string path, CancellationToken canc
return await GetContentAsync(message.Response.ContentStream, cancellationToken).ConfigureAwait(false);
}
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
catch (Exception ex)
diff --git a/sdk/monitor/Azure.Monitor.Query/src/LogsQueryClient.cs b/sdk/monitor/Azure.Monitor.Query/src/LogsQueryClient.cs
index fe07e2f76e3b8..dc0ee7eccf8ba 100644
--- a/sdk/monitor/Azure.Monitor.Query/src/LogsQueryClient.cs
+++ b/sdk/monitor/Azure.Monitor.Query/src/LogsQueryClient.cs
@@ -719,14 +719,7 @@ Response ConvertBatchResponse(BatchResponse resp
}
default:
{
- if (async)
- {
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
- }
- else
- {
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
- }
+ throw new RequestFailedException(message.Response);
}
}
}
@@ -780,14 +773,7 @@ await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellat
}
default:
{
- if (async)
- {
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
- }
- else
- {
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
- }
+ throw new RequestFailedException(message.Response);
}
}
}
diff --git a/sdk/monitor/Azure.Monitor.Query/tests/LogSenderClient.cs b/sdk/monitor/Azure.Monitor.Query/tests/LogSenderClient.cs
index 1083b179971f6..9ff7800d6c54e 100644
--- a/sdk/monitor/Azure.Monitor.Query/tests/LogSenderClient.cs
+++ b/sdk/monitor/Azure.Monitor.Query/tests/LogSenderClient.cs
@@ -53,7 +53,7 @@ public async Task SendAsync(string tableName, IEnumerable SendAsync(object data)
var response = await _pipeline.SendRequestAsync(request, default);
if (response.Status != 200)
{
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response);
+ throw new RequestFailedException(response);
}
return response;
diff --git a/sdk/personalizer/Azure.AI.Personalizer/src/Generated/EvaluationsRestClient.cs b/sdk/personalizer/Azure.AI.Personalizer/src/Generated/EvaluationsRestClient.cs
index 4e8df6d96cdc8..8e165cac48fa2 100644
--- a/sdk/personalizer/Azure.AI.Personalizer/src/Generated/EvaluationsRestClient.cs
+++ b/sdk/personalizer/Azure.AI.Personalizer/src/Generated/EvaluationsRestClient.cs
@@ -66,7 +66,7 @@ public async Task DeleteAsync(string evaluationId, CancellationToken c
case 204:
return message.Response;
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -88,7 +88,7 @@ public Response Delete(string evaluationId, CancellationToken cancellationToken
case 204:
return message.Response;
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -130,7 +130,7 @@ public async Task> GetAsync(string evaluationId
return Response.FromValue(value, message.Response);
}
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -157,7 +157,7 @@ public Response Get(string evaluationId, CancellationTok
return Response.FromValue(value, message.Response);
}
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -196,7 +196,7 @@ public async Task>> ListAsync(Can
return Response.FromValue(value, message.Response);
}
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -221,7 +221,7 @@ public Response> List(CancellationToken ca
return Response.FromValue(value, message.Response);
}
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -267,7 +267,7 @@ public async Task Cre
return ResponseWithHeaders.FromValue(value, headers, message.Response);
}
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
}
diff --git a/sdk/personalizer/Azure.AI.Personalizer/src/Generated/EventsRestClient.cs b/sdk/personalizer/Azure.AI.Personalizer/src/Generated/EventsRestClient.cs
index 255dc118a554b..a8e45fd2d6bbd 100644
--- a/sdk/personalizer/Azure.AI.Personalizer/src/Generated/EventsRestClient.cs
+++ b/sdk/personalizer/Azure.AI.Personalizer/src/Generated/EventsRestClient.cs
@@ -75,7 +75,7 @@ public async Task RewardAsync(string eventId, PersonalizerRewardOption
case 204:
return message.Response;
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -102,7 +102,7 @@ public Response Reward(string eventId, PersonalizerRewardOptions reward, Cancell
case 204:
return message.Response;
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -140,7 +140,7 @@ public async Task ActivateAsync(string eventId, CancellationToken canc
case 204:
return message.Response;
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -162,7 +162,7 @@ public Response Activate(string eventId, CancellationToken cancellationToken = d
case 204:
return message.Response;
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
}
diff --git a/sdk/personalizer/Azure.AI.Personalizer/src/Generated/LogRestClient.cs b/sdk/personalizer/Azure.AI.Personalizer/src/Generated/LogRestClient.cs
index 33a6221ca3545..cb99251a61716 100644
--- a/sdk/personalizer/Azure.AI.Personalizer/src/Generated/LogRestClient.cs
+++ b/sdk/personalizer/Azure.AI.Personalizer/src/Generated/LogRestClient.cs
@@ -57,7 +57,7 @@ public async Task DeleteAsync(CancellationToken cancellationToken = de
case 204:
return message.Response;
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -72,7 +72,7 @@ public Response Delete(CancellationToken cancellationToken = default)
case 204:
return message.Response;
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -106,7 +106,7 @@ public async Task> GetPropertiesAsync(Cancel
return Response.FromValue(value, message.Response);
}
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -126,7 +126,7 @@ public Response GetProperties(CancellationToken cance
return Response.FromValue(value, message.Response);
}
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
}
diff --git a/sdk/personalizer/Azure.AI.Personalizer/src/Generated/ModelRestClient.cs b/sdk/personalizer/Azure.AI.Personalizer/src/Generated/ModelRestClient.cs
index 8e41037f85e5e..a99fa0f9f67cc 100644
--- a/sdk/personalizer/Azure.AI.Personalizer/src/Generated/ModelRestClient.cs
+++ b/sdk/personalizer/Azure.AI.Personalizer/src/Generated/ModelRestClient.cs
@@ -67,7 +67,7 @@ public async Task> GetAsync(bool? signed = null, CancellationTo
return Response.FromValue(value, message.Response);
}
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -86,7 +86,7 @@ public Response Get(bool? signed = null, CancellationToken cancellationT
return Response.FromValue(value, message.Response);
}
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -124,7 +124,7 @@ public async Task ImportAsync(Stream body, CancellationToken cancellat
case 204:
return message.Response;
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -146,7 +146,7 @@ public Response Import(Stream body, CancellationToken cancellationToken = defaul
case 204:
return message.Response;
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -175,7 +175,7 @@ public async Task ResetAsync(CancellationToken cancellationToken = def
case 204:
return message.Response;
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -190,7 +190,7 @@ public Response Reset(CancellationToken cancellationToken = default)
case 204:
return message.Response;
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -224,7 +224,7 @@ public async Task> GetPropertiesAsync(Canc
return Response.FromValue(value, message.Response);
}
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -244,7 +244,7 @@ public Response GetProperties(CancellationToken can
return Response.FromValue(value, message.Response);
}
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
}
diff --git a/sdk/personalizer/Azure.AI.Personalizer/src/Generated/MultiSlotEventsRestClient.cs b/sdk/personalizer/Azure.AI.Personalizer/src/Generated/MultiSlotEventsRestClient.cs
index 2c935101ff06e..a8a395ea31541 100644
--- a/sdk/personalizer/Azure.AI.Personalizer/src/Generated/MultiSlotEventsRestClient.cs
+++ b/sdk/personalizer/Azure.AI.Personalizer/src/Generated/MultiSlotEventsRestClient.cs
@@ -75,7 +75,7 @@ public async Task RewardAsync(string eventId, PersonalizerRewardMultiS
case 204:
return message.Response;
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -102,7 +102,7 @@ public Response Reward(string eventId, PersonalizerRewardMultiSlotOptions body,
case 204:
return message.Response;
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -140,7 +140,7 @@ public async Task ActivateAsync(string eventId, CancellationToken canc
case 204:
return message.Response;
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -162,7 +162,7 @@ public Response Activate(string eventId, CancellationToken cancellationToken = d
case 204:
return message.Response;
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
}
diff --git a/sdk/personalizer/Azure.AI.Personalizer/src/Generated/MultiSlotRestClient.cs b/sdk/personalizer/Azure.AI.Personalizer/src/Generated/MultiSlotRestClient.cs
index c001a8ef77ceb..8f50c66e56e98 100644
--- a/sdk/personalizer/Azure.AI.Personalizer/src/Generated/MultiSlotRestClient.cs
+++ b/sdk/personalizer/Azure.AI.Personalizer/src/Generated/MultiSlotRestClient.cs
@@ -74,7 +74,7 @@ public async Task> RankAsync(Personali
return Response.FromValue(value, message.Response);
}
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -101,7 +101,7 @@ public Response Rank(PersonalizerRankMultiSlotO
return Response.FromValue(value, message.Response);
}
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
}
diff --git a/sdk/personalizer/Azure.AI.Personalizer/src/Generated/PolicyRestClient.cs b/sdk/personalizer/Azure.AI.Personalizer/src/Generated/PolicyRestClient.cs
index fd3c936e584a3..c97ae73ce4461 100644
--- a/sdk/personalizer/Azure.AI.Personalizer/src/Generated/PolicyRestClient.cs
+++ b/sdk/personalizer/Azure.AI.Personalizer/src/Generated/PolicyRestClient.cs
@@ -63,7 +63,7 @@ public async Task> GetAsync(CancellationToken cance
return Response.FromValue(value, message.Response);
}
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -83,7 +83,7 @@ public Response Get(CancellationToken cancellationToken = de
return Response.FromValue(value, message.Response);
}
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -128,7 +128,7 @@ public async Task> UpdateAsync(PersonalizerPolicy p
return Response.FromValue(value, message.Response);
}
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -155,7 +155,7 @@ public Response Update(PersonalizerPolicy policy, Cancellati
return Response.FromValue(value, message.Response);
}
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -189,7 +189,7 @@ public async Task> ResetAsync(CancellationToken can
return Response.FromValue(value, message.Response);
}
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -209,7 +209,7 @@ public Response Reset(CancellationToken cancellationToken =
return Response.FromValue(value, message.Response);
}
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
}
diff --git a/sdk/personalizer/Azure.AI.Personalizer/src/Generated/RankRestClient.cs b/sdk/personalizer/Azure.AI.Personalizer/src/Generated/RankRestClient.cs
index 24a0be61d7ec2..a3067a12e61d8 100644
--- a/sdk/personalizer/Azure.AI.Personalizer/src/Generated/RankRestClient.cs
+++ b/sdk/personalizer/Azure.AI.Personalizer/src/Generated/RankRestClient.cs
@@ -74,7 +74,7 @@ public async Task> RankAsync(PersonalizerRankOp
return Response.FromValue(value, message.Response);
}
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -101,7 +101,7 @@ public Response Rank(PersonalizerRankOptions rankRequest
return Response.FromValue(value, message.Response);
}
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
}
diff --git a/sdk/personalizer/Azure.AI.Personalizer/src/Generated/ServiceConfigurationRestClient.cs b/sdk/personalizer/Azure.AI.Personalizer/src/Generated/ServiceConfigurationRestClient.cs
index 72fff9d81e1c2..a62932f9083b7 100644
--- a/sdk/personalizer/Azure.AI.Personalizer/src/Generated/ServiceConfigurationRestClient.cs
+++ b/sdk/personalizer/Azure.AI.Personalizer/src/Generated/ServiceConfigurationRestClient.cs
@@ -74,7 +74,7 @@ public async Task> UpdateAsync(Personali
return Response.FromValue(value, message.Response);
}
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -101,7 +101,7 @@ public Response Update(PersonalizerServicePropert
return Response.FromValue(value, message.Response);
}
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -135,7 +135,7 @@ public async Task> GetAsync(Cancellation
return Response.FromValue(value, message.Response);
}
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -155,7 +155,7 @@ public Response Get(CancellationToken cancellatio
return Response.FromValue(value, message.Response);
}
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -195,7 +195,7 @@ public async Task ApplyFromEvaluationAsync(PersonalizerPolicyReference
case 204:
return message.Response;
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -217,7 +217,7 @@ public Response ApplyFromEvaluation(PersonalizerPolicyReferenceOptions body, Can
case 204:
return message.Response;
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
}
diff --git a/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/HttpRequestAndResponse.cs b/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/HttpRequestAndResponse.cs
index dc800f8519a03..34bf2f6273800 100644
--- a/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/HttpRequestAndResponse.cs
+++ b/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/HttpRequestAndResponse.cs
@@ -41,13 +41,13 @@ public HttpRequestAndResponse(
_port = GetPort(_fullyQualifiedNamespace);
}
- internal async Task ThrowIfRequestFailedAsync(Request request, Response response)
+ internal void ThrowIfRequestFailedAsync(Request request, Response response)
{
if ((response.Status >= 200) && (response.Status < 400))
{
return;
}
- RequestFailedException ex = await _diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false);
+ RequestFailedException ex = new RequestFailedException(response);
if (response.Status == (int)HttpStatusCode.Unauthorized)
{
throw new UnauthorizedAccessException(
@@ -274,7 +274,7 @@ private async Task SendHttpRequestAsync(
Response response = await _pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
- await ThrowIfRequestFailedAsync(request, response).ConfigureAwait(false);
+ ThrowIfRequestFailedAsync(request, response);
return response;
}
diff --git a/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/NamespacePropertiesExtensions.cs b/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/NamespacePropertiesExtensions.cs
index 41f551ac6f047..d47c8f9f08919 100644
--- a/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/NamespacePropertiesExtensions.cs
+++ b/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/NamespacePropertiesExtensions.cs
@@ -33,7 +33,7 @@ public static async Task ParseResponseAsync(Response respon
throw new ServiceBusException(
false,
"Unknown error.",
- innerException: await diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false));
+ innerException: new RequestFailedException(response));
}
private static async Task ParseFromEntryElementAsync(XElement xEntry, Response response, ClientDiagnostics diagnostics)
@@ -48,7 +48,7 @@ private static async Task ParseFromEntryElementAsync(XEleme
throw new ServiceBusException(
false,
"Unknown error.",
- innerException: await diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false));
+ innerException: new RequestFailedException(response));
}
foreach (var element in nsInfoXml.Elements())
diff --git a/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/QueuePropertiesExtensions.cs b/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/QueuePropertiesExtensions.cs
index 79e21e4b728a2..94f5559406d2d 100644
--- a/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/QueuePropertiesExtensions.cs
+++ b/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/QueuePropertiesExtensions.cs
@@ -78,7 +78,7 @@ public static async Task ParseResponseAsync(Response response,
throw new ServiceBusException(
"Queue was not found",
ServiceBusFailureReason.MessagingEntityNotFound,
- innerException: await diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false));
+ innerException: new RequestFailedException(response));
}
private static async Task ParseFromEntryElementAsync(XElement xEntry, Response response, ClientDiagnostics diagnostics)
@@ -93,7 +93,7 @@ private static async Task ParseFromEntryElementAsync(XElement x
throw new ServiceBusException(
"Queue was not found",
ServiceBusFailureReason.MessagingEntityNotFound,
- innerException: await diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false));
+ innerException: new RequestFailedException(response));
}
var properties = new QueueProperties(name);
@@ -223,7 +223,7 @@ public static async Task> ParsePagedResponseAsync(Response
throw new ServiceBusException(
"No queues were found",
ServiceBusFailureReason.MessagingEntityNotFound,
- innerException: await diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false));
+ innerException: new RequestFailedException(response));
}
public static void NormalizeDescription(this QueueProperties description, string baseAddress)
diff --git a/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/QueueRuntimePropertiesExtensions.cs b/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/QueueRuntimePropertiesExtensions.cs
index c70bdc2e40572..f5af8e7791057 100644
--- a/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/QueueRuntimePropertiesExtensions.cs
+++ b/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/QueueRuntimePropertiesExtensions.cs
@@ -34,7 +34,7 @@ public static async Task ParseResponseAsync(Response res
throw new ServiceBusException(
"Queue was not found",
ServiceBusFailureReason.MessagingEntityNotFound,
- innerException: await diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false));
+ innerException: new RequestFailedException(response));
}
private static async Task ParseFromEntryElementAsync(XElement xEntry, Response response, ClientDiagnostics diagnostics)
@@ -50,7 +50,7 @@ private static async Task ParseFromEntryElementAsync(XEl
throw new ServiceBusException(
"Queue was not found",
ServiceBusFailureReason.MessagingEntityNotFound,
- innerException: await diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false));
+ innerException: new RequestFailedException(response));
}
foreach (var element in qdXml.Elements())
@@ -131,7 +131,7 @@ public static async Task> ParsePagedResponseAsync(R
throw new ServiceBusException(
"No queues were found",
ServiceBusFailureReason.MessagingEntityNotFound,
- innerException: await diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false));
+ innerException: new RequestFailedException(response));
}
}
}
diff --git a/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/Rules/RuleDescriptionExtensions.cs b/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/Rules/RuleDescriptionExtensions.cs
index b193378ed2709..3651e81dda713 100644
--- a/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/Rules/RuleDescriptionExtensions.cs
+++ b/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/Rules/RuleDescriptionExtensions.cs
@@ -64,7 +64,7 @@ public static async Task ParseResponseAsync(Response response, C
throw new ServiceBusException(
"Rule was not found",
ServiceBusFailureReason.MessagingEntityNotFound,
- innerException: await diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false));
+ innerException: new RequestFailedException(response));
}
public static async Task> ParsePagedResponseAsync(Response response, ClientDiagnostics diagnostics)
@@ -96,7 +96,7 @@ public static async Task> ParsePagedResponseAsync(Response
throw new ServiceBusException(
"Rule was not found",
ServiceBusFailureReason.MessagingEntityNotFound,
- innerException: await diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false));
+ innerException: new RequestFailedException(response));
}
private static RuleProperties ParseFromEntryElement(XElement xEntry)
diff --git a/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/SubscriptionPropertiesExtensions.cs b/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/SubscriptionPropertiesExtensions.cs
index 1f5c3fa939ee4..81b0b63942f33 100644
--- a/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/SubscriptionPropertiesExtensions.cs
+++ b/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/SubscriptionPropertiesExtensions.cs
@@ -59,7 +59,7 @@ public static async Task ParseResponseAsync(string topic
throw new ServiceBusException(
"Subscription was not found",
ServiceBusFailureReason.MessagingEntityNotFound,
- innerException: await diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false));
+ innerException: new RequestFailedException(response));
}
public static async Task> ParsePagedResponseAsync(string topicName, Response response, ClientDiagnostics diagnostics)
@@ -92,7 +92,7 @@ public static async Task> ParsePagedResponseAsync(s
throw new ServiceBusException(
"No subscriptions were found",
ServiceBusFailureReason.MessagingEntityNotFound,
- innerException: await diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false));
+ innerException: new RequestFailedException(response));
}
private static async Task ParseFromEntryElementAsync(string topicName, XElement xEntry, Response response, ClientDiagnostics diagnostics)
@@ -108,7 +108,7 @@ private static async Task ParseFromEntryElementAsync(str
throw new ServiceBusException(
"Subscription was not found",
ServiceBusFailureReason.MessagingEntityNotFound,
- innerException: await diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false));
+ innerException: new RequestFailedException(response));
}
foreach (var element in subscriptionXml.Elements())
diff --git a/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/SubscriptionRuntimePropertiesExtensions.cs b/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/SubscriptionRuntimePropertiesExtensions.cs
index 2ee036bff0e03..a85ed15a1b6f1 100644
--- a/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/SubscriptionRuntimePropertiesExtensions.cs
+++ b/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/SubscriptionRuntimePropertiesExtensions.cs
@@ -22,7 +22,7 @@ public static async Task ParseResponseAsync(strin
{
if (xDoc.Name.LocalName == "entry")
{
- return await ParseFromEntryElementAsync(topicName, xDoc, response, diagnostics).ConfigureAwait(false);
+ return ParseFromEntryElement(topicName, xDoc, response, diagnostics);
}
}
}
@@ -34,10 +34,10 @@ public static async Task ParseResponseAsync(strin
throw new ServiceBusException(
"Subscription was not found",
ServiceBusFailureReason.MessagingEntityNotFound,
- innerException: await diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false));
+ innerException: new RequestFailedException(response));
}
- private static async Task ParseFromEntryElementAsync(string topicName, XElement xEntry, Response response, ClientDiagnostics diagnostics)
+ private static void SubscriptionRuntimeProperties ParseFromEntryElement(string topicName, XElement xEntry, Response response, ClientDiagnostics diagnostics)
{
var name = xEntry.Element(XName.Get("title", AdministrationClientConstants.AtomNamespace)).Value;
var subscriptionRuntimeInfo = new SubscriptionRuntimeProperties(topicName, name);
@@ -50,7 +50,7 @@ private static async Task ParseFromEntryElementAs
throw new ServiceBusException(
"Subscription was not found",
ServiceBusFailureReason.MessagingEntityNotFound,
- innerException: await diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false));
+ innerException: new RequestFailedException(response));
}
foreach (var element in qdXml.Elements())
@@ -110,7 +110,7 @@ public static async Task> ParsePagedResponse
var entryList = xDoc.Elements(XName.Get("entry", AdministrationClientConstants.AtomNamespace));
foreach (var entry in entryList)
{
- subscriptionList.Add(await ParseFromEntryElementAsync(topicPath, entry, response, diagnostics).ConfigureAwait(false));
+ subscriptionList.Add(ParseFromEntryElement(topicPath, entry, response, diagnostics));
}
return subscriptionList;
@@ -125,7 +125,7 @@ public static async Task> ParsePagedResponse
throw new ServiceBusException(
"No subscriptions were found",
ServiceBusFailureReason.MessagingEntityNotFound,
- innerException: await diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false));
+ innerException: new RequestFailedException(response));
}
}
}
diff --git a/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/TopicPropertiesExtensions.cs b/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/TopicPropertiesExtensions.cs
index 5a5ac87fa00dd..64e8b3a871a88 100644
--- a/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/TopicPropertiesExtensions.cs
+++ b/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/TopicPropertiesExtensions.cs
@@ -35,7 +35,7 @@ public static async Task ParseResponseAsync(Response response,
throw new ServiceBusException(
"Topic was not found",
ServiceBusFailureReason.MessagingEntityNotFound,
- innerException: await diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false));
+ innerException: new RequestFailedException(response));
}
public static async Task> ParsePagedResponseAsync(Response response, ClientDiagnostics diagnostics)
@@ -68,7 +68,7 @@ public static async Task> ParsePagedResponseAsync(Response
throw new ServiceBusException(
"No topics were found",
ServiceBusFailureReason.MessagingEntityNotFound,
- innerException: await diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false));
+ innerException: new RequestFailedException(response));
}
private static async Task ParseFromEntryElementAsync(XElement xEntry, Response response, ClientDiagnostics diagnostics)
@@ -82,7 +82,7 @@ private static async Task ParseFromEntryElementAsync(XElement x
throw new ServiceBusException(
"Topic was not found",
ServiceBusFailureReason.MessagingEntityNotFound,
- innerException: await diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false));
+ innerException: new RequestFailedException(response));
}
var topicProperties = new TopicProperties(name);
diff --git a/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/TopicRuntimePropertiesExtensions.cs b/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/TopicRuntimePropertiesExtensions.cs
index 65c5d82c07079..a3fd5aa93209b 100644
--- a/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/TopicRuntimePropertiesExtensions.cs
+++ b/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/TopicRuntimePropertiesExtensions.cs
@@ -34,7 +34,7 @@ public static async Task ParseResponseAsync(Response res
throw new ServiceBusException(
"Topic was not found",
ServiceBusFailureReason.MessagingEntityNotFound,
- innerException: await diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false));
+ innerException: new RequestFailedException(response));
}
public static async Task ParseFromEntryElementAsync(XElement xEntry, Response response, ClientDiagnostics diagnostics)
@@ -50,7 +50,7 @@ public static async Task ParseFromEntryElementAsync(XEle
throw new ServiceBusException(
"Topic was not found",
ServiceBusFailureReason.MessagingEntityNotFound,
- innerException: await diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false));
+ innerException: new RequestFailedException(response));
}
foreach (var element in qdXml.Elements())
@@ -120,7 +120,7 @@ public static async Task> ParsePagedResponseAsync(R
throw new ServiceBusException(
"No topics were found",
ServiceBusFailureReason.MessagingEntityNotFound,
- innerException: await diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false));
+ innerException: new RequestFailedException(response));
}
}
}
diff --git a/sdk/storage/Azure.Storage.Blobs.Batch/src/Azure.Storage.Blobs.Batch.csproj b/sdk/storage/Azure.Storage.Blobs.Batch/src/Azure.Storage.Blobs.Batch.csproj
index e4162cc20a687..978f78f1ef0b1 100644
--- a/sdk/storage/Azure.Storage.Blobs.Batch/src/Azure.Storage.Blobs.Batch.csproj
+++ b/sdk/storage/Azure.Storage.Blobs.Batch/src/Azure.Storage.Blobs.Batch.csproj
@@ -23,6 +23,9 @@
+
+
+
diff --git a/sdk/storage/Azure.Storage.Blobs.Batch/src/BatchErrors.cs b/sdk/storage/Azure.Storage.Blobs.Batch/src/BatchErrors.cs
index ebf6bab9c786f..ea364946110c1 100644
--- a/sdk/storage/Azure.Storage.Blobs.Batch/src/BatchErrors.cs
+++ b/sdk/storage/Azure.Storage.Blobs.Batch/src/BatchErrors.cs
@@ -48,6 +48,6 @@ public static InvalidOperationException InvalidHttpHeaderLine(string headerLine)
new InvalidOperationException($"Expected an HTTP header line, not {headerLine}");
public static RequestFailedException InvalidResponse(ClientDiagnostics clientDiagnostics, Response response, Exception innerException) =>
- clientDiagnostics.CreateRequestFailedException(response, new ResponseError(null, "Invalid response"), innerException: innerException);
+ new RequestFailedException(response, innerException, new ResponseError(null, "Invalid response"));
}
}
diff --git a/sdk/storage/Azure.Storage.Blobs.Batch/src/BlobBatch.cs b/sdk/storage/Azure.Storage.Blobs.Batch/src/BlobBatch.cs
index 5abe31b16f5f7..3a62b8d7f2d85 100644
--- a/sdk/storage/Azure.Storage.Blobs.Batch/src/BlobBatch.cs
+++ b/sdk/storage/Azure.Storage.Blobs.Batch/src/BlobBatch.cs
@@ -216,7 +216,7 @@ public virtual Response DeleteBlob(
return new DelayedResponse(
message,
- async response =>
+ response =>
{
switch (response.Status)
{
@@ -224,7 +224,7 @@ public virtual Response DeleteBlob(
BlobDeleteHeaders blobDeleteHeaders = new BlobDeleteHeaders(response);
return ResponseWithHeaders.FromValue(blobDeleteHeaders, response);
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false);
+ throw new RequestFailedException(response);
}
});
}
@@ -327,7 +327,7 @@ public virtual Response SetBlobAccessTier(
return new DelayedResponse(
message,
- async response =>
+ response =>
{
switch (response.Status)
{
@@ -336,7 +336,7 @@ public virtual Response SetBlobAccessTier(
BlobSetAccessTierHeaders blobSetAccessTierHeaders = new BlobSetAccessTierHeaders(response);
return ResponseWithHeaders.FromValue(blobSetAccessTierHeaders, response);
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false);
+ throw new RequestFailedException(response);
}
});
}
diff --git a/sdk/storage/Azure.Storage.Blobs.Batch/src/BlobBatchClient.cs b/sdk/storage/Azure.Storage.Blobs.Batch/src/BlobBatchClient.cs
index 83177317b2562..9d61ea16aefd5 100644
--- a/sdk/storage/Azure.Storage.Blobs.Batch/src/BlobBatchClient.cs
+++ b/sdk/storage/Azure.Storage.Blobs.Batch/src/BlobBatchClient.cs
@@ -576,7 +576,7 @@ private async ValueTask UpdateOperationResponses(
{
// We'll re-process this response as a batch result
- throw ClientDiagnostics.CreateRequestFailedException(responses[0]);
+ throw new RequestFailedException(responses[0]);
}
else
{
@@ -600,7 +600,7 @@ private async ValueTask UpdateOperationResponses(
value is DelayedResponse response)
{
#pragma warning disable AZC0110 // DO NOT use await keyword in possibly synchronous scope.
- await response.SetLiveResponse(responses[i], throwOnAnyFailure).ConfigureAwait(false);
+ response.SetLiveResponse(responses[i], throwOnAnyFailure);
#pragma warning restore AZC0110 // DO NOT use await keyword in possibly synchronous scope.
}
}
diff --git a/sdk/storage/Azure.Storage.Blobs.Batch/src/DelayedResponse.cs b/sdk/storage/Azure.Storage.Blobs.Batch/src/DelayedResponse.cs
index da1fd390997e9..b04f4e6c2ccf8 100644
--- a/sdk/storage/Azure.Storage.Blobs.Batch/src/DelayedResponse.cs
+++ b/sdk/storage/Azure.Storage.Blobs.Batch/src/DelayedResponse.cs
@@ -30,7 +30,7 @@ internal class DelayedResponse : Response
/// BlobRestClient.Group.OperationName_CreateResponse methods which
/// correctly throw when necessary.
///
- private readonly Func> _processResponse;
+ private readonly Func _processResponse;
///
/// Gets the live Response or throws an InvalidOperationException if
@@ -50,7 +50,7 @@ private Response LiveResponse
/// An optional function that can be used to process the response. It
/// is responsible for parsing response bodies and throwing exceptions.
///
- public DelayedResponse(HttpMessage message, Func> processResponse = null)
+ public DelayedResponse(HttpMessage message, Func processResponse = null)
{
// Have the BatchPipelineTransport associate this response with the
// message when it's sent.
@@ -66,7 +66,7 @@ public DelayedResponse(HttpMessage message, Func> proce
/// A value indicating whether or not we should throw for Response
/// failures.
///
- public async Task SetLiveResponse(Response live, bool throwOnFailure)
+ public void SetLiveResponse(Response live, bool throwOnFailure)
{
_live = live;
@@ -74,7 +74,7 @@ public async Task SetLiveResponse(Response live, bool throwOnFailure)
// tries to catch the exception but then interrogate raw responses
if (throwOnFailure && _processResponse != null)
{
- _live = await _processResponse(_live).ConfigureAwait(false);
+ _live = _processResponse(_live);
}
}
diff --git a/sdk/storage/Azure.Storage.Blobs.Batch/tests/DelayedResponseTests.cs b/sdk/storage/Azure.Storage.Blobs.Batch/tests/DelayedResponseTests.cs
index 5d9cf02bf536d..40124ed42675d 100644
--- a/sdk/storage/Azure.Storage.Blobs.Batch/tests/DelayedResponseTests.cs
+++ b/sdk/storage/Azure.Storage.Blobs.Batch/tests/DelayedResponseTests.cs
@@ -19,10 +19,10 @@ public void DelayedResponseToStringDoesntThrow()
}
[Test]
- public async Task CompletedDelayedResponseToStringCallsBase()
+ public void CompletedDelayedResponseToStringCallsBase()
{
DelayedResponse delayedResponse = new DelayedResponse(new HttpMessage(new MockRequest(), new ResponseClassifier()));
- await delayedResponse.SetLiveResponse(new MockResponse(200, "Yay"), false);
+ delayedResponse.SetLiveResponse(new MockResponse(200, "Yay"), false);
Assert.AreEqual("Status: 200, ReasonPhrase: Yay", delayedResponse.ToString());
}
}
diff --git a/sdk/storage/Azure.Storage.Files.DataLake/src/ErrorExtensions.cs b/sdk/storage/Azure.Storage.Files.DataLake/src/ErrorExtensions.cs
deleted file mode 100644
index a6cefbd4e7fcc..0000000000000
--- a/sdk/storage/Azure.Storage.Files.DataLake/src/ErrorExtensions.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Text;
-using System.Text.Json;
-using System.Xml.Linq;
-using Azure.Core.Pipeline;
-using Azure.Storage.Files.DataLake.Models;
-
-namespace Azure.Storage.Files.DataLake
-{
- internal static class ErrorExtensions
- {
-// clientDiagnostics parameter is a pattern expected by the codegenerator
-#pragma warning disable CA1801
- internal static Exception CreateException(this string body, ClientDiagnostics clientDiagnostics, Response response)
-#pragma warning restore CA1801
- {
- // xml
- if (response.Headers.ContentType != null
- && response.Headers.ContentType.Contains("application/xml"))
- {
- XElement error = XDocument.Parse(body).Element("Error");
- string code = error.Element("Code").Value.ToString(CultureInfo.InvariantCulture);
- string message = error.Element("Message").Value.ToString(CultureInfo.InvariantCulture);
- return clientDiagnostics.CreateRequestFailedException(
- response: response,
- new ResponseError(code, message));
- }
- // json
- else if (response.Headers.ContentType != null
- && response.Headers.ContentType.Contains("application/json"))
- {
- using JsonDocument json = JsonDocument.Parse(body);
- JsonElement error = json.RootElement.GetProperty("error");
-
- IDictionary details = default;
- if (error.TryGetProperty("detail", out JsonElement detail))
- {
- details = new Dictionary();
- foreach (JsonProperty property in detail.EnumerateObject())
- {
- details[property.Name] = property.Value.GetString();
- }
- }
-
- return clientDiagnostics.CreateRequestFailedException(
- response: response,
- new ResponseError(
- error.GetProperty("code").GetString(),
- error.GetProperty("message").GetString()
- ),
- additionalInfo: details);
- }
- else
- {
- return new RequestFailedException(
- status: response.Status,
- errorCode: response.Status.ToString(CultureInfo.InvariantCulture),
- message: response.ReasonPhrase,
- innerException: new Exception());
- }
- }
- }
-}
diff --git a/sdk/tables/Azure.Data.Tables/src/TableClient.cs b/sdk/tables/Azure.Data.Tables/src/TableClient.cs
index 7c02a181c81aa..bdd69ef08971f 100644
--- a/sdk/tables/Azure.Data.Tables/src/TableClient.cs
+++ b/sdk/tables/Azure.Data.Tables/src/TableClient.cs
@@ -1355,7 +1355,7 @@ internal async Task DeleteEntityInternal(
return message.Response.Status switch
{
404 or 204 => message.Response,
- _ => throw _diagnostics.CreateRequestFailedException(message.Response),
+ _ => throw new RequestFailedException(message.Response),
};
}
catch (Exception ex)
diff --git a/sdk/tables/Azure.Data.Tables/src/TableRestClient.cs b/sdk/tables/Azure.Data.Tables/src/TableRestClient.cs
index 48185045ec68d..040e621999330 100644
--- a/sdk/tables/Azure.Data.Tables/src/TableRestClient.cs
+++ b/sdk/tables/Azure.Data.Tables/src/TableRestClient.cs
@@ -124,7 +124,7 @@ public Response> SendBatchRequest(HttpMessage message, C
throw ex;
}
default:
- throw ClientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
diff --git a/sdk/testcommon/Azure.Graph.Rbac/src/Generated/ApplicationsRestOperations.cs b/sdk/testcommon/Azure.Graph.Rbac/src/Generated/ApplicationsRestOperations.cs
index 32fe759eab123..ad018ba5455d7 100644
--- a/sdk/testcommon/Azure.Graph.Rbac/src/Generated/ApplicationsRestOperations.cs
+++ b/sdk/testcommon/Azure.Graph.Rbac/src/Generated/ApplicationsRestOperations.cs
@@ -93,7 +93,7 @@ public async Task> CreateAsync(ApplicationCreateParameters
return Response.FromValue(value, message.Response);
}
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -120,7 +120,7 @@ public Response Create(ApplicationCreateParameters parameters, Canc
return Response.FromValue(value, message.Response);
}
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -161,7 +161,7 @@ public async Task> ListAsync(string filter = nul
return Response.FromValue(value, message.Response);
}
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -182,7 +182,7 @@ public Response List(string filter = null, CancellationTo
return Response.FromValue(value, message.Response);
}
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -221,7 +221,7 @@ public async Task DeleteAsync(string applicationObjectId, Cancellation
case 204:
return message.Response;
default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
+ throw new RequestFailedException(message.Response);
}
}
@@ -243,7 +243,7 @@ public Response Delete(string applicationObjectId, CancellationToken cancellatio
case 204:
return message.Response;
default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
+ throw new RequestFailedException(message.Response);
}
}
@@ -287,7 +287,7 @@ public async Task