Skip to content

Commit

Permalink
Added additional info to exceptions for Blobs, Share Files, and DataL…
Browse files Browse the repository at this point in the history
…ake (#15986)
  • Loading branch information
seanmcc-msft authored Oct 16, 2020
1 parent ad47d5d commit 3224238
Show file tree
Hide file tree
Showing 19 changed files with 1,106 additions and 5 deletions.
1 change: 1 addition & 0 deletions sdk/storage/Azure.Storage.Blobs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 12.7.0-preview.2 (Unreleased)
- Fixed bug where BobContainerClient.SetAccessPolicy() would throw an exception if signed identifier permissions were not in the correct order.
- Added seekability to BaseBlobClient.OpenRead().
- Added additional info to exception messages.

## 12.7.0-preview.1 (2020-09-30)
- Added support for service version 2020-02-10.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,13 @@ static partial void CustomizeFromXml(XElement root, StorageError error)
/// <param name="clientDiagnostics">The <see cref="ClientDiagnostics"/> instance to use.</param>
/// <param name="response">The failed response.</param>
/// <returns>A RequestFailedException.</returns>
public Exception CreateException(ClientDiagnostics clientDiagnostics, Azure.Response response)
=> clientDiagnostics.CreateRequestFailedExceptionWithContent(response, message: Message, content: null, response.GetErrorCode(Code));
public Exception CreateException(ClientDiagnostics clientDiagnostics, Response response)
=> clientDiagnostics.CreateRequestFailedExceptionWithContent(
response,
message: Message,
content: null,
response.GetErrorCode(Code),
AdditionalInformation);
}

/// <summary>
Expand Down
21 changes: 21 additions & 0 deletions sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4443,6 +4443,27 @@ await TestHelper.AssertExpectedExceptionAsync<RequestFailedException>(
e => Assert.AreEqual("BlobNotFound", e.ErrorCode));
}

[Test]
public async Task AcquireLeaseAsync_ExtendedExceptionMessage()
{
await using DisposingContainer test = await GetTestContainerAsync();
// Arrange
BlobBaseClient blob = await GetNewBlobClient(test.Container);

string leaseId = Recording.Random.NewGuid().ToString();
TimeSpan duration = TimeSpan.FromSeconds(10);
BlobLeaseClient blobLeaseClient = InstrumentClient(blob.GetBlobLeaseClient(leaseId));

// Act
await TestHelper.AssertExpectedExceptionAsync<RequestFailedException>(
blobLeaseClient.AcquireAsync(duration),
e =>
{
Assert.AreEqual(BlobErrorCode.InvalidHeaderValue.ToString(), e.ErrorCode);
Assert.IsTrue(e.Message.Contains($"Additional Information:{Environment.NewLine}HeaderName: x-ms-lease-duration{Environment.NewLine}HeaderValue: 10"));
});
}

[Test]
public async Task RenewLeaseAsync()
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3224238

Please sign in to comment.