Class TransactionCanceledException
- Namespace
- DynaSharp
- Assembly
- DynaSharp.dll
The whole transaction was cancelled, so none of its actions took effect. Not retried by the client, because repeating the same transaction usually meets the same cause. ReasonFor(TransactMarker) says what became of an action, ItemFor(TransactMarker) what its condition saw, Failures which actions failed, and CancellationReasons holds what DynamoDB sent.
public sealed class TransactionCanceledException : DynamoDbException, ISerializable
- Inheritance
-
TransactionCanceledException
- Implements
- Inherited Members
Remarks
A TransactWriteItems call is cancelled when a condition does not hold, when an item takes part in another transaction,
when a table is throttled, when an item or an index grows too large, and when an action is invalid. A TransactGetItems
call is cancelled when it conflicts with a concurrent write or is throttled. Some causes pass (a conflict, throttling), so
whether to repeat the transaction is the decision of the caller, who can look at the reasons; TransactionFailure says which.
DynamoDB lists the codes in its message and nothing else, one per action in their order: [None, ConditionalCheckFailed], where None is an action that caused no problem and was cancelled with the rest (None). After client.TransactWrite() or client.TransactGet(), Message gains a
line that names each action that failed by its position, verb and table, with its code: Action 2 of 2, Put on Users: ConditionalCheckFailed. It holds no key and no value.
Constructors
TransactionCanceledException(string, IReadOnlyList<CancellationReason>?, string?, HttpStatusCode)
Initializes a new instance of the TransactionCanceledException class.
public TransactionCanceledException(string message, IReadOnlyList<CancellationReason>? cancellationReasons = null, string? requestId = null, HttpStatusCode statusCode = HttpStatusCode.BadRequest)
Parameters
messagestringThe error message returned by DynamoDB.
cancellationReasonsIReadOnlyList<CancellationReason>The reasons, one per action and in the order of the actions. null is treated as none.
requestIdstringThe AWS request id, if known.
statusCodeHttpStatusCodeThe HTTP status code of the response.
Properties
CancellationReasons
Gets the reasons, one for each action of the request and in the same order: the reason at an index belongs to the action at
that index. An action that caused no problem has the code None. Empty when DynamoDB sends no reasons, for example for a
cancellation that is not tied to a particular action. Never null.
public IReadOnlyList<CancellationReason> CancellationReasons { get; }
Property Value
Failures
Gets the actions that made the transaction fail, in the order of the transaction, each with its position and reason: every action but those that caused no problem. It holds no keys or values, so it is what to log. Empty when DynamoDB sends no reasons.
public IReadOnlyList<TransactionActionFailure> Failures { get; }
Property Value
Message
Gets the message of the service, followed for a command by a line that names the actions that failed.
public override string Message { get; }
Property Value
Methods
ItemFor(TransactMarker)
Gets the item the condition of an action saw, when the action set ReturnOldOnFailure(), its condition failed and an item existed. On a typed table,
To<T>() reads it as the entity.
public Item? ItemFor(TransactMarker marker)
Parameters
markerTransactMarkerThe marker of the action.
Returns
Exceptions
- ArgumentException
The marker is a default value, so the action was never added.
ReasonFor(TransactMarker)
Gets what became of an action.
public TransactionFailure ReasonFor(TransactMarker marker)
Parameters
markerTransactMarkerThe marker of the action.
Returns
- TransactionFailure
The reason. None if this action caused no problem, which does not mean it took effect: nothing did. Unknown for a code this library does not know, and when DynamoDB sent no reason for the action. Failures tells the two apart: it lists an unknown code as an entry with that reason, whose Index finds the code in CancellationReasons, and a transaction without reasons has no entries.
Exceptions
- ArgumentException
The marker is a default value, so the action was never added.