Module: LogStruct::Integrations::ActionMailer::ErrorHandling
- Extended by:
- ActiveSupport::Concern, T::Sig
- Defined in:
- lib/log_struct/integrations/action_mailer/error_handling.rb
Overview
Handles error handling for ActionMailer
IMPORTANT LIMITATIONS:
- This module must be included BEFORE users define rescue_from handlers to ensure proper handler precedence (user handlers are checked first)
- Rails rescue_from handlers don't bubble to parent class handlers after reraise
- Handler order matters: Rails checks rescue_from handlers in reverse declaration order
Class Method Summary collapse
-
.install_handler(base) ⇒ void
This will be called when the module is included/prepended.
-
.prepended(base) ⇒ void
Also support prepended (used by tests and manual setup).
Instance Method Summary collapse
-
#log_and_ignore_error(ex) ⇒ void
protected
Just log the error without reporting or retrying.
-
#log_and_report_error(ex) ⇒ void
protected
Log and report to error service, but doesn't reraise.
-
#log_and_reraise_error(ex) ⇒ void
protected
Log, report to error service, and reraise for retry.
Class Method Details
.install_handler(base) ⇒ void
This method returns an undefined value.
This will be called when the module is included/prepended
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/log_struct/integrations/action_mailer/error_handling.rb', line 24 def self.install_handler(base) # Only add the handler once per class return if base.instance_variable_get(:@_logstruct_handler_installed) # Add our handler FIRST so it has lower priority than user handlers base.rescue_from StandardError, with: :log_and_reraise_error # Mark as installed to prevent duplicates base.instance_variable_set(:@_logstruct_handler_installed, true) end |
.prepended(base) ⇒ void
This method returns an undefined value.
Also support prepended (used by tests and manual setup)
41 42 43 |
# File 'lib/log_struct/integrations/action_mailer/error_handling.rb', line 41 def self.prepended(base) install_handler(base) end |
Instance Method Details
#log_and_ignore_error(ex) ⇒ void (protected)
This method returns an undefined value.
Just log the error without reporting or retrying
49 50 51 |
# File 'lib/log_struct/integrations/action_mailer/error_handling.rb', line 49 def log_and_ignore_error(ex) log_email_delivery_error(ex, notify: false, report: false, reraise: false) end |
#log_and_report_error(ex) ⇒ void (protected)
This method returns an undefined value.
Log and report to error service, but doesn't reraise.
55 56 57 |
# File 'lib/log_struct/integrations/action_mailer/error_handling.rb', line 55 def log_and_report_error(ex) log_email_delivery_error(ex, notify: false, report: true, reraise: false) end |
#log_and_reraise_error(ex) ⇒ void (protected)
This method returns an undefined value.
Log, report to error service, and reraise for retry
61 62 63 |
# File 'lib/log_struct/integrations/action_mailer/error_handling.rb', line 61 def log_and_reraise_error(ex) log_email_delivery_error(ex, notify: false, report: true, reraise: true) end |