Sha256: 14da615bd2f6be7db1c68545cf5ad1f715ec9d1113e3969338e0cec66d3c5b5a

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

require "resque/failure/base"
require "resque/failure/multiple"

module Bugsnag
  class Resque < ::Resque::Failure::Base
    def self.configure(&block)
      add_failure_backend
      Bugsnag.configure(&block)
    end

    def self.add_failure_backend
      return if ::Resque::Failure.backend == self

      # Ensure resque is using a "Multiple" failure backend
      unless ::Resque::Failure.backend < ::Resque::Failure::Multiple
        original_backend = ::Resque::Failure.backend
        ::Resque::Failure.backend = ::Resque::Failure::Multiple
        ::Resque::Failure.backend.classes ||= []
        ::Resque::Failure.backend.classes << original_backend
      end

      # Add Bugsnag failure backend
      unless ::Resque::Failure.backend.classes.include?(self)
        ::Resque::Failure.backend.classes << self
      end
    end

    def save
      Bugsnag.auto_notify(exception, {:context => "resque##{queue}", :payload => payload})
    end
  end
end

# For backwards compatibility
Resque::Failure::Bugsnag = Bugsnag::Resque

# Auto-load the failure backend
Bugsnag::Resque.add_failure_backend

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bugsnag-1.6.3 lib/bugsnag/resque.rb
bugsnag-1.6.2 lib/bugsnag/resque.rb
bugsnag-1.6.1 lib/bugsnag/resque.rb
bugsnag-1.6.0 lib/bugsnag/resque.rb