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.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/bugsnag/integrations/rake.rb', line 45

def execute_with_bugsnag(args=nil)
  Bugsnag.configuration.detected_app_type = "rake"

  old_task = Bugsnag.configuration.request_data[:bugsnag_running_task]
  Bugsnag.configuration.set_request_data :bugsnag_running_task, self
  Bugsnag.configuration.runtime_versions["rake"] = ::Rake::VERSION

  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