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
Instance Attribute Summary collapse
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.
Instance Attribute Details
#logstruct_mail_failed ⇒ Boolean?
19 20 21 |
# File 'lib/log_struct/integrations/action_mailer/error_handling.rb', line 19 def logstruct_mail_failed @logstruct_mail_failed end |
Class Method Details
.install_handler(base) ⇒ void
This method returns an undefined value.
This will be called when the module is included/prepended
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/log_struct/integrations/action_mailer/error_handling.rb', line 27 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)
44 45 46 |
# File 'lib/log_struct/integrations/action_mailer/error_handling.rb', line 44 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
52 53 54 55 |
# File 'lib/log_struct/integrations/action_mailer/error_handling.rb', line 52 def log_and_ignore_error(ex) self.logstruct_mail_failed = true 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.
59 60 61 |
# File 'lib/log_struct/integrations/action_mailer/error_handling.rb', line 59 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
65 66 67 |
# File 'lib/log_struct/integrations/action_mailer/error_handling.rb', line 65 def log_and_reraise_error(ex) log_email_delivery_error(ex, notify: false, report: true, reraise: true) end |