AshWorkflow.Errors.UndoNotPermitted exception (AshWorkflow v0.6.0)

Copy Markdown View Source

Raised (or returned) when undo is called on a record that cannot be rewound.

The reason field says which rule refused, so callers can branch without matching on message text:

  • :undo_not_enabled — the workflow has no undo block.
  • :no_history — the record's transition log has no state change to undo.
  • :not_undoable — the last state change came from a transition that is not marked undoable?: true. Automatic steps, timeouts, error paths and the initial row all land here.
  • :window_expired — the transition is older than the configured within.
  • :different_actorsame_actor? is set and the actor differs from the one recorded on the transition.
  • :no_actorsame_actor? is set and either the caller or the recorded transition has no actor.
  • :stale — the record moved on between reading the log and writing, so the row being undone is no longer the head.

Summary

Types

reason()

@type reason() ::
  :undo_not_enabled
  | :no_history
  | :not_undoable
  | :window_expired
  | :different_actor
  | :no_actor
  | :stale

Functions

exception(args)

@spec exception(opts :: Keyword.t()) :: %AshWorkflow.Errors.UndoNotPermitted{
  __exception__: true,
  bread_crumbs: term(),
  class: term(),
  from_state: term(),
  path: term(),
  reason: term(),
  resource: term(),
  splode: term(),
  stacktrace: term(),
  to_state: term(),
  vars: term()
}

Create an Elixir.AshWorkflow.Errors.UndoNotPermitted without raising it.

Keys

  • :reason
  • :resource
  • :from_state
  • :to_state