Class: Bugsnag::Middleware::ExceptionMetaData

Inherits:
Object
  • Object
show all
Defined in:
lib/bugsnag/middleware/exception_meta_data.rb

Overview

Extracts data from the exception.

Instance Method Summary collapse

Constructor Details

#initialize(bugsnag) ⇒ ExceptionMetaData

Returns a new instance of ExceptionMetaData.



5
6
7
# File 'lib/bugsnag/middleware/exception_meta_data.rb', line 5

def initialize(bugsnag)
  @bugsnag = bugsnag
end

Instance Method Details

#call(report) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/bugsnag/middleware/exception_meta_data.rb', line 9

def call(report)
  # Apply the user's information attached to the exceptions
  report.raw_exceptions.each do |exception|
    if exception.respond_to?(:bugsnag_user_id) && exception.bugsnag_user_id.is_a?(String)
      report.user = {id: exception.bugsnag_user_id}
    end

    if exception.respond_to?(:bugsnag_context) && exception.bugsnag_context.is_a?(String)
      report.context = exception.bugsnag_context
    end

    if exception.respond_to?(:bugsnag_grouping_hash) && exception.bugsnag_grouping_hash.is_a?(String)
      report.grouping_hash = exception.bugsnag_grouping_hash
    end

    if exception.respond_to?(:bugsnag_meta_data) && exception..is_a?(Hash)
      exception..each do |key, value|
        report.add_tab key, value
      end
    end
  end

  @bugsnag.call(report)
end