Sha256: 0930a3ae6a200ecb9c3cae538d429ed245388e165629e4ef7f3b9d5e95dd2e91

Contents?: true

Size: 1.64 KB

Versions: 6

Compression:

Stored size: 1.64 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
    attr_reader :custom_data

    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]
      @custom_data = params[:custom_data] || {}
    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,
        :custom_data => @custom_data
      }.to_json
    end

    def reporter
      {
        :name => "Errplane",
        :version => Errplane::VERSION,
        :url => "https://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

6 entries across 6 versions & 1 rubygems

Version Path
errplane-0.2.7 lib/errplane/black_box.rb
errplane-0.2.6 lib/errplane/black_box.rb
errplane-0.2.5 lib/errplane/black_box.rb
errplane-0.2.4 lib/errplane/black_box.rb
errplane-0.2.3 lib/errplane/black_box.rb
errplane-0.2.0 lib/errplane/black_box.rb