| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Globalization; |
| | 6 | | using Azure.Storage.Blobs.Models; |
| | 7 | |
|
| | 8 | | namespace Azure.Storage.Blobs |
| | 9 | | { |
| | 10 | | /// <summary> |
| | 11 | | /// Create exceptions for common error cases. |
| | 12 | | /// </summary> |
| | 13 | | internal class BlobErrors : Errors |
| | 14 | | { |
| | 15 | | public static ArgumentOutOfRangeException BlobConditionsMustBeDefault(params string[] conditions) => |
| 8 | 16 | | new ArgumentOutOfRangeException($"The {string.Join(" and ", conditions)} conditions must have their default |
| | 17 | |
|
| | 18 | | public static InvalidOperationException BlobOrContainerMissing(string leaseClient, |
| | 19 | | string blobBaseClient, |
| | 20 | | string blobContainerClient) => |
| 0 | 21 | | new InvalidOperationException($"{leaseClient} requires either a {blobBaseClient} or {blobContainerClient}"); |
| | 22 | |
|
| | 23 | | public static ArgumentException InvalidDateTimeUtc(string dateTime) => |
| 4 | 24 | | new ArgumentException($"{dateTime} must be UTC"); |
| | 25 | |
|
| | 26 | | internal static void VerifyHttpsCustomerProvidedKey(Uri uri, CustomerProvidedKey? customerProvidedKey) |
| | 27 | | { |
| 29090 | 28 | | if (customerProvidedKey.HasValue && !string.Equals(uri.Scheme, Constants.Https, StringComparison.OrdinalIgno |
| | 29 | | { |
| 28 | 30 | | throw new ArgumentException("Cannot use client-provided key without HTTPS."); |
| | 31 | | } |
| 29062 | 32 | | } |
| | 33 | |
|
| | 34 | | internal static void VerifyCpkAndEncryptionScopeNotBothSet(CustomerProvidedKey? customerProvidedKey, string encr |
| | 35 | | { |
| 28838 | 36 | | if (customerProvidedKey.HasValue && encryptionScope != null) |
| | 37 | | { |
| 0 | 38 | | throw new ArgumentException("CustomerProvidedKey and EncryptionScope cannot both be set"); |
| | 39 | | } |
| 28838 | 40 | | } |
| | 41 | |
|
| | 42 | | public static ArgumentException ParsingFullHttpRangeFailed(string range) |
| 0 | 43 | | => new ArgumentException("Could not obtain the total length from HTTP range " + range); |
| | 44 | | } |
| | 45 | | } |