Sha256: 8545eac3e068d43a35af7815d6fce89380d3dbd1d005c3e9f5291479a82141bf

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

module Errplane
  class BlackBox
    attr_reader :exception
    attr_reader :params
    attr_reader :session_data
    attr_reader :controller
    attr_reader :action
    attr_reader :request_url

    def initialize(params = {})
      @exception = params[:exception]
      @params = params[:params] || {}
      @session_data = params[:session_data] || {}
      @controller = params[:controller]
      @action = params[:action]
      @request_url = params[:request_url]
    end

    def to_json
      {
        :time => Time.now.to_i,
        :application_name => Errplane.configuration.application_name,
        :application_root => Errplane.configuration.application_root,
        :framework => Errplane.configuration.framework,
        :framework_version => Errplane.configuration.framework_version,
        :message => @exception.message,
        :backtrace => @exception.backtrace || [],
        :exception_class => @exception.class.to_s,
        :language => "Ruby",
        :language_version => "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}",
        :environment_variables => ENV.to_hash,
        :reporter => reporter,
        :request_data => request_data
      }.to_json
    end

    def reporter
      {
        :name => "Errplane",
        :version => Errplane::VERSION,
        :url => "http://github.com/errplane/gem"
      }
    end

    def request_data
      {
        :params => @params,
        :session_data => @session_data,
        :controller => @controller,
        :action => @action,
        :request_url => @request_url
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
errplane-0.1.9 lib/errplane/black_box.rb