Sha256: d782d33f3b632b7d3fffb2815062ba5eacd1fd846e8ac45acded2f48e8b11b3d
Contents?: true
Size: 1002 Bytes
Versions: 2
Compression:
Stored size: 1002 Bytes
Contents
require 'action_dispatch' require 'exception_notifier/notifier' class ExceptionNotifier def self.default_ignore_exceptions [].tap do |exceptions| exceptions << ActiveRecord::RecordNotFound if defined? ActiveRecord exceptions << AbstractController::ActionNotFound if defined? AbstractController exceptions << ActionController::RoutingError if defined? ActionController end end def initialize(app, options = {}) @app, @options = app, options @options[:ignore_exceptions] ||= self.class.default_ignore_exceptions end def call(env) env["exception_notifier.options"] ||= {} env["exception_notifier.options"].merge!(@options) @app.call(env) rescue Exception => exception options = env['exception_notifier.options'] unless Array.wrap(options[:ignore_exceptions]).include?(exception.class) Notifier.exception_notification(env, exception).deliver env['exception_notifier.delivered'] = true end raise exception end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
xaop-exception_notification-1.0.2 | lib/exception_notifier.rb |
xaop-exception_notification-1.0.1 | lib/exception_notifier.rb |