Sha256: d72d5a2873e7b59f2549942c43aed0a5786475255bffdfb01c52ebad0c16e336

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

require 'bugsnag'
require 'exception_notifier'

module ExceptionNotifier
  class BugsnagNotifier
    def initialize(options=nil)
      @default_options = options || {}
    end

    def call(exception, options={}, &block)
      options = @default_options.merge(options)

      wrapped_block = proc do |report|
        options.each do |key, value|
          # NOTE: `: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 below:
          # - https://github.com/smartinez87/exception_notification/blob/2443af19e4c7433c7439c6ff01922a54023b89dd/lib/exception_notification/rack.rb#L51
          # - https://github.com/bugsnag/bugsnag-ruby/blob/46d345d93dcb715c977615d24b369da204ed7b72/lib/bugsnag/middleware/rack_request.rb#L74-L76
          # - https://docs.bugsnag.com/platforms/ruby/rails/configuration-options/#send_environment
          if key == :env
            if report.configuration.send_environment
              report.add_tab(:environment, value)
            end
          else
            report.public_send("#{key}=", value)
          end
        end

        block.call(report) if block
      end

      Bugsnag.notify(exception, &wrapped_block)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
exception_notification-bugsnag-0.3.0 lib/bugsnag/exception_notification.rb