Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save HowardvanRooijen/eaf4a1068cd5734b1976 to your computer and use it in GitHub Desktop.
Save HowardvanRooijen/eaf4a1068cd5734b1976 to your computer and use it in GitHub Desktop.
StorageWriteExceptionRetryPolicy extension for Endjin.Retry
#region Using Directives
using System;
using System.Diagnostics;
using System.Net;
using Endjin.Core.Retry.Policies;
using Endjin.Kpi.Core.Extensions;
using Microsoft.WindowsAzure.Storage;
#endregion
public class StorageWriteExceptionRetryPolicy : IRetryPolicy
{
public bool CanRetry(Exception ex)
{
Trace.TraceError(ex.GetFullExceptionMessage());
var we = ex as WebException;
if (we != null && we.Status == WebExceptionStatus.ProtocolError)
{
return false;
}
var se = ex as StorageException;
if (se != null && se.RequestInformation.HttpStatusCode == (int)HttpStatusCode.Conflict)
{
return false;
}
return ex is LeaseException;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment