Table of Contents

Class DynamoDbException

Namespace
DynaSharp
Assembly
DynaSharp.dll

An error returned by DynamoDB. Specific errors have derived types; all others surface as this type with their ErrorCode. IsTransient says whether trying again later can help.

public class DynamoDbException : Exception, ISerializable
Inheritance
DynamoDbException
Implements
Derived
Inherited Members

Examples

try
{
    await orders.Put(order).IfNotExists().SendAsync(ct);
}
catch (ConditionalCheckFailedException)
{
    Console.WriteLine("The order exists already.");
}
catch (DynamoDbException exception) when (exception.IsTransient)
{
    Console.WriteLine("DynamoDB is busy. Try again later.");
}

Constructors

DynamoDbException(string, string, HttpStatusCode, string?, Exception?)

Initializes a new instance of the DynamoDbException class.

public DynamoDbException(string message, string errorCode, HttpStatusCode statusCode, string? requestId = null, Exception? innerException = null)

Parameters

message string

The error message returned by DynamoDB.

errorCode string

The DynamoDB error code without namespace, for example ValidationException.

statusCode HttpStatusCode

The HTTP status code of the response.

requestId string

The AWS request id from the x-amzn-RequestId header, for support cases.

innerException Exception

The underlying failure, if any.

Properties

ErrorCode

Gets the DynamoDB error code without namespace, for example ValidationException.

public string ErrorCode { get; }

Property Value

string

IsTransient

Gets a value indicating whether the same call can succeed later without any change, as IsTransient says it for a database.

public bool IsTransient { get; }

Property Value

bool

Remarks

true for throttling and capacity errors (ProvisionedThroughputExceededException, ThrottlingException, RequestLimitExceededException, LimitExceededException, TransactionInProgressException), for a server error, which is InternalServerErrorException and any code with HTTP 500, 502, 503 or 504, a body that is no DynamoDB response included, for the code RequestTimeoutException, for ReplicatedWriteConflictException, for TransactionConflictException, and for a TransactionCanceledException whose every failed action is TransactionConflict or Throttled. A BatchIncompleteException or BatchGetIncompleteException<T> is transient when its rounds ran out on what DynamoDB left unprocessed, and when the failure in its InnerException is: what is left may pass later.

The client already retried every transient failure that its retry policy repeats before the exception reaches the caller, so true means that its attempts ran out, or its retry quota, or that MaxAttempts is 1: try later, after a wait, and not at once in a loop. The policy repeats everything above but the conflicts of a transaction, which RetryOnConflictAsync with TransactionConflict runs again.

false for everything else: a rejected request (ValidationException), a missing or wrong table or index (ResourceNotFoundException, ResourceInUseException), access, signature and token errors (AccessDeniedException, UnrecognizedClientException, and the codes InvalidSignatureException, MissingAuthenticationTokenException and ExpiredTokenException), an item or item collection over its size limit, an expired stream iterator, a reused transaction token, and a code this library does not know, unless its status is one of a server error. A failed condition is false, a ConditionalCheckFailedException and a cancelled transaction with a ConditionalCheckFailed reason, because the same call cannot succeed unless the item changes: read it and decide anew, which RetryOnConflictAsync does.

A failure that does not come from DynamoDB is no DynamoDbException, so it has no such property: the TimeoutException of an attempt and an HttpRequestException of the network are transient and were retried as well, except one whose HttpRequestError is ConfigurationLimitExceeded, and an OperationCanceledException and a CredentialsUnavailableException, which is also what a rejection by STS surfaces as, are not.

OperationName

Gets the DynamoDB operation that failed, for example PutItem. Set by the client on every error that DynamoDB (or a proxy answering for it) returns; null on an exception made elsewhere. The message stays the one DynamoDB sent, which often does not say what was called.

public string? OperationName { get; }

Property Value

string

RequestId

Gets the AWS request id, or null if the response had none.

public string? RequestId { get; }

Property Value

string

StatusCode

Gets the HTTP status code of the response.

public HttpStatusCode StatusCode { get; }

Property Value

HttpStatusCode

TableName

Gets the table the failed call addressed, exactly as the request named it (a name or an ARN). null when the call has no single table: a batch or transaction (which may span several), ListTables, or a ListStreams without a table. Never a key or a value.

public string? TableName { get; }

Property Value

string

Methods

ToString()

public override string ToString()

Returns

string

Remarks

The text of ToString(), followed by a line with OperationName and TableName when they are known.