Sha256: 9c152a213ceef26a158d3fade42d17ddcec0506b9e136ac22dab22fea41aab4f

Contents?: true

Size: 671 Bytes

Versions: 1

Compression:

Stored size: 671 Bytes

Contents

module Resque
  module Failure
    class GeneratesPagerdutyDesc
      MAX_LENGTH = 120
      OMISSION = '...'

      def initialize(exception, payload)
        @exception = exception
        @payload = payload
      end

      def execute
        if full_message.length > MAX_LENGTH
          full_message.slice(0, MAX_LENGTH - OMISSION.length) + OMISSION
        else
          full_message
        end
      end

      def self.execute(exception, payload)
        new(exception, payload).execute
      end

      private

      def full_message
        @full_message ||= "#{@exception.class} in #{@payload['class']}: #{@exception.message}"
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
resque-pagerduty-0.1.1 lib/resque/failure/generates_pagerduty_desc.rb