Sha256: 94ae4b09d5b05f53a9ca5f644025a46f73cf9387bd063f122ec0dd25d7e0958d

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

module Chatterbox::ExceptionNotification
  class Extracter
    def self.wrap(notification = {})
      new(notification).notice
    end

    def initialize(notification)
      @notification = notification
    end

    def notice
      hash = extract_exception_info(@notification)
      hash = extract_ruby_info(hash)
      extract_default_info(hash)
    end

    def extract_default_info(hash)
      hsh = { :summary       => "N/A",
              :environment   => ENV.to_hash,
              :chatterbox_info => "Chatterbox Version #{Chatterbox::Version::STRING}"
      }.merge(hash)
    end

    def extract_exception_info(hash)
      return hash unless hash.key?(:exception)
      exception = hash[:exception]
      {
        :summary => "#{exception.class.name}: #{exception.message}",
        :error_class   => exception.class.name,
        :error_message => exception.message,
        :backtrace     => exception.backtrace,
      }.merge(hash)
    end

    def extract_ruby_info(hash)
      hash.merge({ 
        :ruby_info => {
          :ruby_version  => RUBY_VERSION,
          :ruby_platform => RUBY_PLATFORM
        }
      })
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
chatterbox-0.8.5 lib/chatterbox/exception_notification/extracter.rb
chatterbox-0.8.4 lib/chatterbox/exception_notification/extracter.rb
chatterbox-0.8.3 lib/chatterbox/exception_notification/extracter.rb