Skip to content
  • Jeremy Daer's avatar
    6b543166
    Action Mailer: Declarative exception handling with `rescue_from`. · 6b543166
    Jeremy Daer authored
    Follows the same pattern as controllers and jobs. Exceptions raised in
    delivery jobs (enqueued by `#deliver_later`) are also delegated to the
    mailer's rescue_from handlers, so you can handle the DeserializationError
    raised by delivery jobs:
    
    ```ruby
    class MyMailer < ApplicationMailer
      rescue_from ActiveJob::DeserializationError do
        …
      end
    ```
    
    ActiveSupport::Rescuable polish:
    * Add the `rescue_with_handler` class method so exceptions may be
      handled at the class level without requiring an instance.
    * Rationalize `exception.cause` handling. If no handler matches the
      exception, fall back to the handler that matches its cause.
    * Handle exceptions raised elsewhere. Pass `object: …` to execute
      the `rescue_from` handler (e.g. a method call or a block to
      instance_exec) against a different object. Defaults to `self`.
    6b543166
    Action Mailer: Declarative exception handling with `rescue_from`.
    Jeremy Daer authored
    Follows the same pattern as controllers and jobs. Exceptions raised in
    delivery jobs (enqueued by `#deliver_later`) are also delegated to the
    mailer's rescue_from handlers, so you can handle the DeserializationError
    raised by delivery jobs:
    
    ```ruby
    class MyMailer < ApplicationMailer
      rescue_from ActiveJob::DeserializationError do
        …
      end
    ```
    
    ActiveSupport::Rescuable polish:
    * Add the `rescue_with_handler` class method so exceptions may be
      handled at the class level without requiring an instance.
    * Rationalize `exception.cause` handling. If no handler matches the
      exception, fall back to the handler that matches its cause.
    * Handle exceptions raised elsewhere. Pass `object: …` to execute
      the `rescue_from` handler (e.g. a method call or a block to
      instance_exec) against a different object. Defaults to `self`.
Loading