Module: Axn::Internal::PipingError
- Defined in:
- lib/axn/internal/piping_error.rb
Overview
Handles errors from “piping” code - hooks, callbacks, and other non-critical code paths that shouldn’t break the main action flow. Errors are logged (or raised in development if configured) rather than propagating.
Class Method Summary collapse
Class Method Details
.swallow(desc, exception:, action: nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/axn/internal/piping_error.rb', line 9 def self.swallow(desc, exception:, action: nil) # If raise_piping_errors_in_dev is enabled and we're in development, raise instead of log. # Test and production environments always swallow the error to match production behavior. raise exception if Axn.config.raise_piping_errors_in_dev && Axn.config.env.development? # Extract just filename/line number from backtrace src = exception.backtrace.first.split.first.split("/").last.split(":")[0, 2].join(":") = if Axn.config.env.production? "Ignoring exception raised while #{desc}: #{exception.class.name} - #{exception.} (from #{src})" else msg = "!! IGNORING EXCEPTION RAISED WHILE #{desc.upcase} !!\n\n" \ "\t* Exception: #{exception.class.name}\n" \ "\t* Message: #{exception.}\n" \ "\t* From: #{src}" "#{'⌵' * 30}\n\n#{msg}\n\n#{'^' * 30}" end (action || Axn.config.logger).send(:warn, ) nil end |