Module: Axn::Internal::ExceptionClassification

Defined in:
lib/axn/internal/exception_classification.rb

Overview

Per-execution (per call-tree) record of how exceptions were handled, so a nested call! that re-raises the SAME exception object up the stack doesn't (a) report it more than once, or (b) lose a fails_on classification an inner action made.

Scoped via IsolatedExecutionState and cleared when the nesting stack empties (see NestingTracking) — so the same exception object re-raised by a LATER, independent run is treated fresh, never silently suppressed.

The sets key on the exception OBJECT (identity), not its object_id: holding the object keeps it reachable for the call tree's lifetime, so there is no freed-then-reused object_id to collide. compare_by_identity also makes this immune to exceptions that override ==/eql?/hash. Bounded by the number of exceptions actually raised in one tree, and dropped wholesale on reset!.

Class Method Summary collapse

Class Method Details

.failure?(exception) ⇒ Boolean

fails_on stickiness: a classified failure stays a failure (no report, failure outcome) as it bubbles up — mirroring how Axn::Failure is sticky via its class.

Returns:

  • (Boolean)


25
# File 'lib/axn/internal/exception_classification.rb', line 25

def failure?(exception) = _failures.include?(exception)

.mark_failure!(exception) ⇒ Object



26
# File 'lib/axn/internal/exception_classification.rb', line 26

def mark_failure!(exception) = _failures.add(exception)

.mark_reported!(exception) ⇒ Object



21
# File 'lib/axn/internal/exception_classification.rb', line 21

def mark_reported!(exception) = _reported.add(exception)

.reported?(exception) ⇒ Boolean

Global report de-duplication: report once per exception per call tree.

Returns:

  • (Boolean)


20
# File 'lib/axn/internal/exception_classification.rb', line 20

def reported?(exception) = _reported.include?(exception)

.reset!Object

Called by NestingTracking when the outermost action finishes.



29
30
31
32
# File 'lib/axn/internal/exception_classification.rb', line 29

def reset!
  ActiveSupport::IsolatedExecutionState[:_axn_reported_exceptions] = nil
  ActiveSupport::IsolatedExecutionState[:_axn_failure_exceptions] = nil
end