DoubleEntryLedger.Workers.CommandWorker.UpdateCommandError exception (double_entry_ledger v0.1.0)

View Source

Custom exception for handling errors when update commands can't be processed due to issues with their corresponding create commands.

This exception is raised when attempting to process an update command but the original create_command is either not found, pending, or failed. In the double-entry ledger system, update commands modify existing entities, so they can only be processed after their create_commands have been successfully processed.

Usage

This exception is typically raised in the CommandWorker when processing an update command:

iex> raise UpdateCommandError,
...>   update_command: update_command,
...>   create_command: create_command
** (UpdateCommandError) Create command (id: ...) not yet processed for Update Command (id: ...)

Reasons

The exception struct includes a :reason field, which can be one of:

  • :create_command_not_processed — The create command exists but is not yet processed (pending, processing, occ_timeout, or failed)
  • :create_command_in_dead_letter — The create command is in the dead letter state
  • :create_command_not_found — The create command could not be found

Fields

  • :message — Human-readable error message
  • :create_command — The create command struct (may be nil)
  • :update_command — The update command struct
  • :reason — Atom describing the error reason

Example

try do
  # ...code that may raise UpdateCommandError...
rescue
  e in UpdateCommandError ->
    IO.inspect(e.reason)
    IO.inspect(e.message)
end

Summary

Types

t()

@type t() :: %DoubleEntryLedger.Workers.CommandWorker.UpdateCommandError{
  __exception__: true,
  create_command: DoubleEntryLedger.Command.t() | nil,
  message: String.t(),
  reason: atom(),
  update_command: DoubleEntryLedger.Command.t()
}