Error Handling
DynamoDBError is a sealed trait that represents all the possible errors that can occur when interacting with DynamoDB
and is returned by the DynamoDBQuery execute
method.
def execute: ZIO[DynamoDBExecutor, DynamoDBError, Out] = ???
The error hierarchy is as follows:
DynamoDBError
top level sealed traitDynamoDBError.ItemError
sealed trait for item level errorsDynamoDBError.ItemError.ValueNotFound
- returned byget
in the High Level API. If you expect items to be missing you can use themaybeFound
extension method to returnNone
in this scenario. see Working Withget
Return Values for more details.DynamoDBError.ItemError.DecodingError
- returned by automatic codecs in the High Level API when data does not match the expected type described by the schema
DynamoDBError.AWSError
- case class that contains the underlying AWSException
. Typically, you need to pattern match on this when you expect a specific AWS exception eg AWSConditionalCheckFailedException
when you do a strict insert operation by having a condition expression that asserts the primary key does not exist.DynamoDBError.BatchError
sealed trait for batch related errors. You need to consider this error if queries result in batching eg if you are usingDynamoDBQuery.forEach
or manuallyZip
'ing togetherDynamoDBQuery
's or using utility functions that useDynamoDBQuery.forEach
. Note at the point that this error is raised automatic retries have already occurred. For a long running process typical handler actions would be to record the errors and to carry on processing. See Auto batching and parallelisation section for more details.DynamoDBError.BatchError.GetError
- case class returned by automatic batching -unprocessedKeys
contains a Map of table name to primary keyDynamoDBError.BatchError.WriteError
- returned by automatic batching -unprocessedItems
contains a map of table name to item/primary key
DynamoDBError.TransactionError
sealed trait for transaction related errors. You need to handle this error if you are using the transaction API ie<dynamoDBQuery>.transaction
or<dynamoDBQuery>.safeTransaction
DynamoDBError.TransactionError.EmptyTransaction
DynamoDBError.TransactionError.MixedTransactionTypes
DynamoDBError.TransactionError.InvalidTransactionActions