Sha256: a4183c5c3cf22507e63ab275f216c0be9ccf82e3da52953f18c8850f6fbcdec2

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 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
      }.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

2 entries across 2 versions & 1 rubygems

Version Path
chatterbox-0.8.2 lib/chatterbox/exception_notification/extracter.rb
chatterbox-0.8.1 lib/chatterbox/exception_notification/extracter.rb