class ExceptionNotifier::BugsnagNotifier
Public Class Methods
new(options=nil)
click to toggle source
# File lib/bugsnag/exception_notification.rb, line 6 def initialize(options=nil) @default_options = options || {} end
Public Instance Methods
call(exception, options={}, &block)
click to toggle source
# File lib/bugsnag/exception_notification.rb, line 10 def call(exception, options={}, &block) options = @default_options.merge(options) wrapped_block = proc do |report| options.each do |key, value| case when support_rack?(key) process_rack(report, value) when support_sidekiq?(key, value) process_sidekiq(report, value) when support_resque?(key, value) process_resque(report, value) # Support any attributes. when report.respond_to?("#{key}=") report.public_send("#{key}=", value) # Just warn instead of an error because it's tough to support # all data formats which ExceptionNotification may pass. else warn "#{self.class.name} does not know the data: `#{key.inspect}=>#{value.inspect}`" end end block.call(report) if block end Bugsnag.notify(exception, &wrapped_block) end
Private Instance Methods
process_rack(report, value)
click to toggle source
# File lib/bugsnag/exception_notification.rb, line 52 def process_rack(report, value) if report.configuration.send_environment report.add_tab(:environment, value) end end
process_resque(report, value)
click to toggle source
# File lib/bugsnag/exception_notification.rb, line 76 def process_resque(report, value) report.add_tab(:resque, value[:resque]) end
process_sidekiq(report, value)
click to toggle source
# File lib/bugsnag/exception_notification.rb, line 65 def process_sidekiq(report, value) report.add_tab(:sidekiq, value[:sidekiq]) end
support_rack?(key)
click to toggle source
`:env` option can be passed as a Rack Env object by `ExceptionNotification::Rack`. Bugsnag provides the way to report the Env object by default.
@see github.com/smartinez87/exception_notification/blob/v4.3.0/lib/exception_notification/rack.rb#L51 @see github.com/bugsnag/bugsnag-ruby/blob/v6.0.0/lib/bugsnag/middleware/rack_request.rb#L61-L63 @see docs.bugsnag.com/platforms/ruby/rails/configuration-options/#send_environment
# File lib/bugsnag/exception_notification.rb, line 48 def support_rack?(key) key == :env end
support_resque?(key, value)
click to toggle source
Support Resque data format.
@see github.com/smartinez87/exception_notification/blob/v4.3.0/lib/exception_notification/resque.rb#L20
# File lib/bugsnag/exception_notification.rb, line 72 def support_resque?(key, value) key == :data && value.is_a?(Hash) && value.include?(:resque) end
support_sidekiq?(key, value)
click to toggle source
Support Sidekiq data format.
@see github.com/smartinez87/exception_notification/blob/v4.3.0/lib/exception_notification/sidekiq.rb#L28
# File lib/bugsnag/exception_notification.rb, line 61 def support_sidekiq?(key, value) key == :data && value.is_a?(Hash) && value.include?(:sidekiq) end