aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/lib/action_mailer/rescuable.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionmailer/lib/action_mailer/rescuable.rb')
-rw-r--r--actionmailer/lib/action_mailer/rescuable.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/actionmailer/lib/action_mailer/rescuable.rb b/actionmailer/lib/action_mailer/rescuable.rb
new file mode 100644
index 0000000000..5b567eb500
--- /dev/null
+++ b/actionmailer/lib/action_mailer/rescuable.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+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