/
TableTransactionFailedException.cs
56 lines (51 loc) · 1.99 KB
/
TableTransactionFailedException.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace Azure.Data.Tables
{
/// <summary>
///
/// </summary>
[Serializable]
public class TableTransactionFailedException : RequestFailedException
{
/// <summary>
/// The index position of the <see cref="TableTransactionAction"/> collection submitted to <see cref="TableClient.SubmitTransaction"/> or
/// <see cref="TableClient.SubmitTransactionAsync"/> which caused the transaction to fail.
/// </summary>
public int? FailedTransactionActionIndex { get; internal set; }
/// <summary>
/// Initializes a new instances of a <see cref="TableTransactionFailedException"/>.
/// </summary>
/// <param name="requestFailedException"> The <see cref="RequestFailedException"/> related to this exception.</param>
public TableTransactionFailedException(RequestFailedException requestFailedException)
: base(
requestFailedException.Status,
requestFailedException.Message,
requestFailedException.ErrorCode,
requestFailedException.InnerException)
{
foreach (var key in requestFailedException.Data.Keys)
{
Data.Add(key, requestFailedException.Data[key]);
}
try
{
if (Data[TableConstants.ExceptionData.FailedEntityIndex] is string stringIndex && int.TryParse(stringIndex, out var index))
{
FailedTransactionActionIndex = index;
}
}
catch
{
// We just don't want to throw here.
}
}
/// <inheritdoc />
protected TableTransactionFailedException(SerializationInfo info, StreamingContext context)
: base(info, context)
{ }
}
}