Exception: Statecraft::StaleTransition
- Inherits:
-
TransitionConflict
- Object
- StandardError
- Error
- TransitionConflict
- Statecraft::StaleTransition
- Defined in:
- lib/statecraft/errors.rb
Overview
The refusal of a seen: token: the snapshot the caller acted on is not the row's version — or could not be read at all, which is the same answer with nothing to compare (expected_version stays nil). A subclass of TransitionConflict, so existing rescues keep catching it; controllers map it to 409 specifically.
Instance Attribute Summary collapse
-
#expected_version ⇒ Object
readonly
Returns the value of attribute expected_version.
-
#seen ⇒ Object
readonly
Returns the value of attribute seen.
Attributes inherited from TransitionConflict
Instance Method Summary collapse
-
#initialize(record:, expected_from:, expected_version:, seen:) ⇒ StaleTransition
constructor
A new instance of StaleTransition.
Constructor Details
#initialize(record:, expected_from:, expected_version:, seen:) ⇒ StaleTransition
Returns a new instance of StaleTransition.
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/statecraft/errors.rb', line 57 def initialize(record:, expected_from:, expected_version:, seen:) @expected_version = expected_version @seen = seen reason = if expected_version.nil? "the token #{seen.inspect} is not a readable version" else "the caller saw version #{seen.inspect}, but the row has moved on" end super(record: record, expected_from: expected_from, message: "stale transition for #{record.class.name}##{record.id}: #{reason}") end |
Instance Attribute Details
#expected_version ⇒ Object (readonly)
Returns the value of attribute expected_version.
55 56 57 |
# File 'lib/statecraft/errors.rb', line 55 def expected_version @expected_version end |
#seen ⇒ Object (readonly)
Returns the value of attribute seen.
55 56 57 |
# File 'lib/statecraft/errors.rb', line 55 def seen @seen end |