DoubleEntryLedger.Workers.CommandWorker.AccountCommandResponseHandler (double_entry_ledger v0.4.0)
View SourceResponse handler for account-related event processing operations.
This module provides standardized response handling for Command processing operations, including success and error scenarios. It handles the translation of database transaction results into appropriate response formats and performs comprehensive logging for audit and debugging purposes.
Key Features
- Response Translation: Converts Ecto.Multi transaction results into standardized responses
- Error Mapping: Maps validation errors from Events and Accounts back to AccountCommandMap changesets
- Comprehensive Logging: Provides detailed logging for success and failure scenarios
Usage
This module is typically used by CommandWorker modules that process Command structures, providing a consistent interface for handling transaction results.
Error Handling
The module handles several types of errors:
- Command validation errors (mapped to event-level changeset errors)
- Account validation errors (mapped to payload-level changeset errors)
- Multi step failures (logged and returned as string errors)
Summary
Types
Error response containing either a changeset with validation errors or a string error message.
Complete response type for event processing operations.
Success response tuple containing the processed account and associated event.
Functions
Handles responses from account event processing operations.
Types
@type error_response() :: {:error, DoubleEntryLedger.Command.t() | Ecto.Changeset.t(DoubleEntryLedger.Command.t())}
Error response containing either a changeset with validation errors or a string error message.
@type logable() :: DoubleEntryLedger.Command.t() | DoubleEntryLedger.Command.AccountCommandMap.t() | DoubleEntryLedger.Command.TransactionCommandMap.t() | map()
@type response() :: success_tuple() | error_response()
Complete response type for event processing operations.
@type success_tuple() :: {:ok, DoubleEntryLedger.Account.t(), DoubleEntryLedger.Command.t()}
Success response tuple containing the processed account and associated event.
Functions
@spec default_response_handler( {:ok, %{ account: DoubleEntryLedger.Account.t(), command_success: DoubleEntryLedger.Command.t() }} | {:error, :atom, any(), map()}, DoubleEntryLedger.Command.t() ) :: response()
Handles responses from account event processing operations.