Sha256: 575f4709c9aad77860ec2ab7785b3d89982451dad0a06395af39bd184bdda58a

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 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)
      { :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

3 entries across 3 versions & 1 rubygems

Version Path
chatterbox-0.6.2 lib/chatterbox/exception_notification/extracter.rb
chatterbox-0.6.1 lib/chatterbox/exception_notification/extracter.rb
chatterbox-0.6.0 lib/chatterbox/exception_notification/extracter.rb