Sha256: 037a72986da3802e50668df84393d85f1261e5f426d7b23bc7a4e7a13878cd99
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
require 'action_dispatch' require 'exception_notifier/notifier' class ExceptionNotifier class << self def 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 background_options @background_options ||= Rails.application.middleware.find {|klass| klass == ExceptionNotifier }.args.first rescue {} end def with(&block) block.call rescue Exception => exception unless Array.wrap(background_options[:ignore_exceptions]).include?(exception.class) Notifier.background_exception_notification(exception).deliver end raise exception end end def initialize(app, options = {}) @app, @options = app, options @options[:ignore_exceptions] ||= self.class.default_ignore_exceptions end def call(env) @app.call(env) rescue Exception => exception options = (env['exception_notifier.options'] ||= {}) options.reverse_merge!(@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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
exception_notification_rails3-1.1.0 | lib/exception_notifier.rb |