Sha256: db6c38bc7642c70709270d6d0bf6b2b1d6b01458a1470453eb53c8626f58f8c5

Contents?: true

Size: 1010 Bytes

Versions: 10

Compression:

Stored size: 1010 Bytes

Contents

require 'bugsnag'

Rake::TaskManager.record_task_metadata = true

class Rake::Task

  FRAMEWORK_ATTRIBUTES = {
    :framework => "Rake"
  }

  ##
  # Executes the rake task with Bugsnag setup with contextual data.
  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

  alias_method :execute_without_bugsnag, :execute
  alias_method :execute, :execute_with_bugsnag
end

Bugsnag.configuration.internal_middleware.use(Bugsnag::Middleware::Rake)

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
bugsnag-6.11.1 lib/bugsnag/integrations/rake.rb
bugsnag-6.11.0 lib/bugsnag/integrations/rake.rb
bugsnag-6.10.0 lib/bugsnag/integrations/rake.rb
bugsnag-6.9.0 lib/bugsnag/integrations/rake.rb
bugsnag-6.8.0 lib/bugsnag/integrations/rake.rb
bugsnag-6.7.3 lib/bugsnag/integrations/rake.rb
bugsnag-6.7.2 lib/bugsnag/integrations/rake.rb
bugsnag-6.7.1 lib/bugsnag/integrations/rake.rb
bugsnag-6.7.0 lib/bugsnag/integrations/rake.rb
bugsnag-6.6.4 lib/bugsnag/integrations/rake.rb