public static StorageException ToStorageException(this AmazonS3Exception asex)
{
switch (asex?.ErrorCode)
{
case "InvalidAccessKeyId":
case "Forbidden":
return new StorageException(StorageErrorCode.InvalidCredentials, asex);
case "InvalidSecurity":
case "AccessDenied":
case "AccountProblem":
case "NotSignedUp":
case "InvalidPayer":
case "RequestTimeTooSkewed":
case "SignatureDoesNotMatch":
return new StorageException(StorageErrorCode.InvalidAccess, asex);
case "NoSuchBucket":
case "NoSuchKey":
case "NoSuchUpload":
case "NoSuchVersion":
return new StorageException(StorageErrorCode.NotFound, asex);
case "InvalidBucketName":
case "KeyTooLong":
return new StorageException(StorageErrorCode.InvalidName, asex);
default:
return new StorageException(StorageErrorCode.GenericException, asex);
}
}
}