Module: Axn::Async::ExceptionReporting
- Defined in:
- lib/axn/async/exception_reporting.rb
Overview
Shared utilities for async exception reporting across adapters. Used by both Sidekiq (death handler) and ActiveJob (after_discard) to build context and trigger on_exception consistently.
Defined Under Namespace
Classes: DiscardedJobAction, DiscardedJobResult
Class Method Summary collapse
-
.trigger_on_exception(exception:, action_class:, retry_context:, job_args:, extra_context: {}, log_prefix: "async") ⇒ Object
Triggers on_exception for an async job that has been discarded/exhausted.
Class Method Details
.trigger_on_exception(exception:, action_class:, retry_context:, job_args:, extra_context: {}, log_prefix: "async") ⇒ Object
Triggers on_exception for an async job that has been discarded/exhausted.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/axn/async/exception_reporting.rb', line 18 def trigger_on_exception(exception:, action_class:, retry_context:, job_args:, extra_context: {}, log_prefix: "async") # Filter sensitive values using the action class's internal _context_slice filtered_context = action_class._context_slice(data: job_args, direction: :inbound) # Build final context with async info (avoid mutating extra_context) async_extra = extra_context[:async] || {} context = filtered_context.merge( async: retry_context.to_h.merge(async_extra), ).merge(extra_context.except(:async)) # Create proxy action for the on_exception interface proxy_action = DiscardedJobAction.new(action_class, exception) # Trigger on_exception Axn.config.on_exception(exception, action: proxy_action, context:) rescue StandardError => e Axn::Internal::PipingError.swallow("in #{log_prefix}", exception: e) end |