Class: Namira::ErrorHelpers::Bugsnag

Inherits:
Object
  • Object
show all
Defined in:
lib/namira/error_helpers.rb

Instance Method Summary collapse

Constructor Details

#initialize(bugsnag) ⇒ Bugsnag

Returns a new instance of Bugsnag.



12
13
14
# File 'lib/namira/error_helpers.rb', line 12

def initialize(bugsnag)
  @bugsnag = bugsnag
end

Instance Method Details

#call(notification) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/namira/error_helpers.rb', line 16

def call(notification)
  notification.exceptions.each do |exception|
    next unless exception.is_a?(Namira::Errors::HTTPError)

    notification.add_tab("Namira #{exception.response.status.to_i}",
      headers: exception.response.headers.to_h,
      body: exception.response.body.to_s[0...200],
      method: exception.response.method.to_s,
      url: exception.response.url.to_s,
      redirected: (exception.response.redirect_count > 0).to_s)
  end

  @bugsnag.call(notification)
end