Skip to content

Commit

Permalink
Log BlobNotFound exception
Browse files Browse the repository at this point in the history
  • Loading branch information
yaroslav-tykhonchuk committed Jan 10, 2024
1 parent a656abd commit bb06d85
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions AzureBatchQueue/MessageQueue.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using Azure;
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Specialized;
using Azure.Storage.Queues;
Expand Down Expand Up @@ -187,8 +188,16 @@ async Task<QueueMessage<T>> ToQueueMessage(QueueMessage m, CancellationToken ct)
var payload = m.Body.ToMemory();
if (IsBlobRef(m.Body, out var blobRef))
{
var blobData = await container.GetBlobClient(blobRef!.BlobName).DownloadContentAsync(ct);
payload = blobData.Value.Content.ToMemory();
try
{
var blobData = await container.GetBlobClient(blobRef!.BlobName).DownloadContentAsync(ct);
payload = blobData.Value.Content.ToMemory();
}
catch (RequestFailedException ex) when (ex.Status == 404)
{
logger.LogError(ex, "Blob with name {blobRef!.BlobName} is not found for {messageId}", blobRef.BlobName, m.MessageId);

Check warning on line 198 in AzureBatchQueue/MessageQueue.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 198 in AzureBatchQueue/MessageQueue.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 198 in AzureBatchQueue/MessageQueue.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 198 in AzureBatchQueue/MessageQueue.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 198 in AzureBatchQueue/MessageQueue.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 198 in AzureBatchQueue/MessageQueue.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
throw;
}
}

var item = serializer.Deserialize(payload);
Expand Down

0 comments on commit bb06d85

Please sign in to comment.