Class: Rake::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/bugsnag/integrations/rake.rb

Constant Summary collapse

FRAMEWORK_ATTRIBUTES =
{
  :framework => "Rake"
}

Instance Method Summary collapse

Instance Method Details

#execute_with_bugsnag(args = nil) ⇒ Object Also known as: execute

Executes the rake task with Bugsnag setup with contextual data.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/bugsnag/integrations/rake.rb', line 13

def execute_with_bugsnag(args=nil)
  Bugsnag.configuration.app_type ||= "rake"
  old_task = Bugsnag.configuration.request_data[:bugsnag_running_task]
  Bugsnag.configuration.set_request_data :bugsnag_running_task, self

  execute_without_bugsnag(args)

rescue Exception => ex
  Bugsnag.notify(ex, true) do |report|
    report.severity = "error"
    report.severity_reason = {
      :type => Bugsnag::Report::UNHANDLED_EXCEPTION_MIDDLEWARE,
      :attributes => FRAMEWORK_ATTRIBUTES
    }
  end
  raise
ensure
  Bugsnag.configuration.set_request_data :bugsnag_running_task, old_task
end