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
33
34
35
36
37
38
39
40
# 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)
      user_id = exception.bugsnag_user_id
      report.user = {id: user_id} if user_id.is_a?(String)
    end

    if exception.respond_to?(:bugsnag_context)
      context = exception.bugsnag_context
      # note: this should set 'context' not 'automatic_context' as it's a
      #       user-supplied value
      report.context = context if context.is_a?(String)
    end

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

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

  @bugsnag.call(report)
end