aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/lib/action_mailer/rescuable.rb
blob: f2eabfa0574f865f9d8e3d54b5023fc73f345fda (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module ActionMailer #:nodoc:
  # Provides `rescue_from` for mailers. Wraps mailer action processing,
  # mail job processing, and mail delivery.
  module Rescuable
    extend ActiveSupport::Concern
    include ActiveSupport::Rescuable

    class_methods do
      def handle_exception(exception) #:nodoc:
        rescue_with_handler(exception) || raise(exception)
      end
    end

    def handle_exceptions #:nodoc:
      yield
    rescue => exception
      rescue_with_handler(exception) || raise
    end

    private
      def process(*)
        handle_exceptions do
          super
        end
      end
  end
end