python_outbox_core.publisher.error_handler

Error handling for outbox event publishing.

Best Practices Applied: 1. Separation of concerns (error handling isolated) 2. Rich error context for debugging 3. Retry decision logic (extensible) 4. Dead Letter Queue (DLQ) support

References: - Error handling patterns: https://aws.amazon.com/message-queue/features/dead-letter-queues/

Classes

OutboxErrorHandler

Handles per-event publishing errors.

Module Contents

class python_outbox_core.publisher.error_handler.OutboxErrorHandler(logger: Any = None, max_retries: int = 3)

Handles per-event publishing errors.

Projects can extend this for custom retry/DLQ logic.

logger
max_retries = 3
handle(event: Any, exception: Exception) None

Log error with full context.

Args:

event: The failed IOutboxEvent instance exception: The exception that was raised

should_retry(event: Any, exception: Exception, attempt: int) bool

Decide if event should be retried.

Override for custom retry logic (e.g., skip retries for validation errors).

Args:

event: The failed IOutboxEvent instance exception: The exception that was raised attempt: Current attempt number (0-indexed)

Returns:

True if should retry, False to mark failed (DLQ)

is_transient_error(exception: Exception) bool

Check if error is transient (network, timeout, etc.).

Override to customize transient error detection.