Class AsyncExceptionMapper
java.lang.Object
dev.hogwai.dynamodb.simplified.internal.AsyncExceptionMapper
Centralized utility for consistent async exception mapping across all async builders.
Usage: All async builder CompletableFuture chains MUST use
.exceptionally(AsyncExceptionMapper.handler("Operation", tableName))
instead of inline .handle() or .exceptionally() with
instanceof checks. The centralized handler correctly unwraps
CompletionException, routes
DynamoDbException → OperationFailedException,
ConditionalCheckFailedException → ConditionFailedException,
and wraps other throwables as DynamoSimplifiedException.
Ensures every async builder wraps exceptions with the same semantics:
ConditionalCheckFailedException→ConditionFailedExceptionDynamoDbException→OperationFailedException- All other
RuntimeException→ rethrown as-is - Checked exceptions → wrapped in
DynamoSimplifiedException
-
Method Summary
Modifier and TypeMethodDescriptionCreates aFunctionsuitable for passing toCompletableFuture.exceptionally(Function).static @NonNull RuntimeExceptionmapException(@NonNull String operation, @Nullable String tableName, @NonNull Throwable cause) Wraps aThrowablefrom aCompletableFuture.exceptionally(Function)handler into the appropriateDynamoSimplifiedExceptionsubtype.
-
Method Details
-
mapException
public static @NonNull RuntimeException mapException(@NonNull String operation, @Nullable String tableName, @NonNull Throwable cause) Wraps aThrowablefrom aCompletableFuture.exceptionally(Function)handler into the appropriateDynamoSimplifiedExceptionsubtype.- Parameters:
operation- the DynamoDB operation name (e.g., "Query", "UpdateItem")tableName- the table name (nullable for cross-table operations)cause- the throwable from the exceptionally handler- Returns:
- never returns: always throws
-
handler
public static <T> @NonNull Function<Throwable, T> handler(@NonNull String operation, @Nullable String tableName) Creates aFunctionsuitable for passing toCompletableFuture.exceptionally(Function).- Type Parameters:
T- the future result type- Parameters:
operation- the DynamoDB operation nametableName- the table name (nullable)- Returns:
- a function that re-throws the wrapped exception
-