| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Collections.Generic; |
| | 6 | | using System.Globalization; |
| | 7 | | using Azure.Core; |
| | 8 | | using Azure.Core.Pipeline; |
| | 9 | |
|
| | 10 | | namespace Azure.Storage.Blobs.Specialized |
| | 11 | | { |
| | 12 | | /// <summary> |
| | 13 | | /// Errors raised by the batching APIs. |
| | 14 | | /// </summary> |
| | 15 | | internal static class BatchErrors |
| | 16 | | { |
| | 17 | | public static InvalidOperationException UseDelayedResponseEarly() => |
| 4 | 18 | | new InvalidOperationException($"Cannot use the {nameof(Response)} before calling {nameof(BlobBatchClient)}.{ |
| | 19 | |
|
| | 20 | | public static ArgumentException CannotResubmitBatch(string argumentName) => |
| 0 | 21 | | new ArgumentException($"Cannot submit a batch that has already been submitted.", argumentName); |
| | 22 | |
|
| | 23 | | public static ArgumentException BatchClientDoesNotMatch(string argumentName) => |
| 4 | 24 | | new ArgumentException($"The {nameof(BlobBatchClient)} used to create the {nameof(BlobBatch)} must be used to |
| | 25 | |
|
| | 26 | | public static ArgumentException CannotSubmitEmptyBatch(string argumentName) => |
| 4 | 27 | | new ArgumentException($"Cannot submit an empty batch.", argumentName); |
| | 28 | |
|
| | 29 | | public static InvalidOperationException BatchAlreadySubmitted() => |
| 0 | 30 | | new InvalidOperationException($"Cannot modify a batch that has already been submitted."); |
| | 31 | |
|
| | 32 | | public static InvalidOperationException OnlyHomogenousOperationsAllowed(BlobBatchOperationType operationType) => |
| 8 | 33 | | new InvalidOperationException($"{nameof(BlobBatch)} only supports one operation type per batch and is alread |
| | 34 | |
|
| | 35 | | public static InvalidOperationException UnexpectedResponseCount(int expected, int actual) => |
| 0 | 36 | | new InvalidOperationException($"Expected {expected.ToString(CultureInfo.InvariantCulture)} responses for the |
| | 37 | |
|
| | 38 | | public static AggregateException ResponseFailures(IList<Exception> failures) => |
| 32 | 39 | | new AggregateException($"{failures.Count.ToString(CultureInfo.InvariantCulture)} batch operation(s) failed." |
| | 40 | |
|
| | 41 | | public static InvalidOperationException InvalidBatchContentType(string contentType) => |
| 0 | 42 | | new InvalidOperationException($"Expected {HttpHeader.Names.ContentType} to start with {BatchConstants.Multip |
| | 43 | |
|
| | 44 | | public static InvalidOperationException InvalidHttpStatusLine(string statusLine) => |
| 0 | 45 | | new InvalidOperationException($"Expected an HTTP status line, not {statusLine}"); |
| | 46 | |
|
| | 47 | | public static InvalidOperationException InvalidHttpHeaderLine(string headerLine) => |
| 0 | 48 | | new InvalidOperationException($"Expected an HTTP header line, not {headerLine}"); |
| | 49 | |
|
| | 50 | | public static RequestFailedException InvalidResponse(ClientDiagnostics clientDiagnostics, Response response, Exc |
| 0 | 51 | | clientDiagnostics.CreateRequestFailedExceptionWithContent(response, message: "Invalid response", innerExcept |
| | 52 | |
|
| | 53 | | } |
| | 54 | | } |