| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. See License.txt in the project root for license information. |
| | 3 | |
|
| | 4 | | namespace Microsoft.Azure.Batch |
| | 5 | | { |
| | 6 | | using System; |
| | 7 | | using System.Collections.Generic; |
| | 8 | | using System.Text; |
| | 9 | | using Microsoft.Azure.Batch.Common; |
| | 10 | |
|
| | 11 | | /// <summary> |
| | 12 | | /// An exception thrown by the Batch client. |
| | 13 | | /// </summary> |
| | 14 | | public class BatchClientException : BatchException |
| | 15 | | { |
| | 16 | | internal BatchClientException(string message = null, Exception inner = null) : base(null, message, inner) |
| | 17 | | { |
| | 18 | | } |
| | 19 | | } |
| | 20 | |
|
| | 21 | | /// <summary> |
| | 22 | | /// The exception that is thrown when the AddTaskCollection operation is terminated. |
| | 23 | | /// </summary> |
| | 24 | | public class AddTaskCollectionTerminatedException : BatchClientException |
| | 25 | | { |
| | 26 | | /// <summary> |
| | 27 | | /// Gets the <see cref="AddTaskResult"/> for the task which caused the exception. |
| | 28 | | /// </summary> |
| | 29 | | /// <remarks> |
| | 30 | | /// More than one task may have failed. In order to see the full list, use an <see cref="AddTaskCollectionResult |
| | 31 | | /// </remarks> |
| | 32 | | public AddTaskResult AddTaskResult { get; } |
| | 33 | |
|
| | 34 | | internal AddTaskCollectionTerminatedException(AddTaskResult result, Exception inner = null) : |
| | 35 | | base(GenerateMessageString(result), inner) |
| | 36 | | { |
| | 37 | | this.AddTaskResult = result; |
| | 38 | | } |
| | 39 | |
|
| | 40 | | private static string GenerateMessageString(AddTaskResult result) |
| | 41 | | { |
| | 42 | | return string.Format(System.Globalization.CultureInfo.InvariantCulture, BatchErrorMessages.AddTaskCollection |
| | 43 | | } |
| | 44 | | } |
| | 45 | |
|
| | 46 | | /// <summary> |
| | 47 | | /// An exception raised when one or more operations in a parallel set of operations fails. |
| | 48 | | /// The <see cref="AggregateException.InnerExceptions"/> collection contains the exceptions for each of the failed o |
| | 49 | | /// </summary> |
| | 50 | | public class ParallelOperationsException : AggregateException |
| | 51 | | { |
| | 52 | | internal ParallelOperationsException(IEnumerable<Exception> innerExceptions) : base(innerExceptions) |
| | 53 | | { |
| | 54 | | } |
| | 55 | |
|
| | 56 | | internal ParallelOperationsException(string message, IEnumerable<Exception> innerExceptions) : base(message, inn |
| | 57 | | { |
| | 58 | | } |
| | 59 | |
|
| | 60 | | /// <summary> |
| | 61 | | /// Creates and returns a string representation of the current <see cref="ParallelOperationsException"/>. |
| | 62 | | /// </summary> |
| | 63 | | /// <returns>A string representation of the current exception.</returns> |
| | 64 | | public override string ToString() |
| | 65 | | { |
| | 66 | | StringBuilder builder = new StringBuilder(); |
| | 67 | | builder.Append($"{this.GetType()}: ").AppendLine(this.Message); |
| | 68 | | builder.AppendLine(this.StackTrace); |
| | 69 | | builder.AppendLine(); |
| | 70 | |
|
| | 71 | | for (int i = 0; i < this.InnerExceptions.Count; i++) |
| | 72 | | { |
| | 73 | | builder.Append($"Exception #{i}:").AppendLine(); |
| | 74 | | builder.Append(this.InnerExceptions[i]).AppendLine().AppendLine(); |
| | 75 | | } |
| | 76 | |
|
| | 77 | | return builder.ToString(); |
| | 78 | | } |
| | 79 | | } |
| | 80 | |
|
| | 81 | | internal class RunOnceException : BatchException |
| | 82 | | { |
| | 83 | | internal RunOnceException(string message = null, Exception inner = null) |
| 0 | 84 | | : base(null, message, inner) |
| | 85 | | { |
| | 86 | |
|
| 0 | 87 | | } |
| | 88 | | } |
| | 89 | | } |