RetryExceptionHelper
Defines commonly used static retry helper functions to decide whether an exception should be retried.
using System;
using System.IO;
using System.Security;
namespace Relativity.DataExchange.Io
{
internal static class RetryExceptionHelper
{
public static Func<Exception, bool> CreateRetryPredicate(RetryOptions options)
{
return (Exception exception) => IsRetryable(exception, options);
}
public static bool IsRetryable(Exception exception, RetryOptions options)
{
if (exception == null)
throw new ArgumentNullException("exception");
if (exception is UnauthorizedAccessException || exception is SecurityException)
return options.HasFlag(RetryOptions.Permissions);
if (exception is FileInfoInvalidPathException || ExceptionHelper.IsIllegalCharactersInPathException(exception))
return false;
if (exception is FileNotFoundException)
return options.HasFlag(RetryOptions.FileNotFound);
if (exception is DirectoryNotFoundException)
return options.HasFlag(RetryOptions.DirectoryNotFound);
if (exception is PathTooLongException)
return false;
if (ExceptionHelper.IsOutOfDiskSpaceException(exception))
return options.HasFlag(RetryOptions.DiskFull);
if (exception is IOException)
return options.HasFlag(RetryOptions.Io);
return false;
}
}
}