Class: Errplane::ExceptionPresenter
- Inherits:
-
Object
- Object
- Errplane::ExceptionPresenter
- Defined in:
- lib/errplane/exception_presenter.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#backtrace ⇒ Object
readonly
Returns the value of attribute backtrace.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#custom_data ⇒ Object
readonly
Returns the value of attribute custom_data.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
-
#hash ⇒ Object
Returns the value of attribute hash.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#referer ⇒ Object
readonly
Returns the value of attribute referer.
-
#remote_ip ⇒ Object
readonly
Returns the value of attribute remote_ip.
-
#request_url ⇒ Object
readonly
Returns the value of attribute request_url.
-
#session_data ⇒ Object
readonly
Returns the value of attribute session_data.
-
#user_agent ⇒ Object
readonly
Returns the value of attribute user_agent.
Instance Method Summary collapse
- #context ⇒ Object
- #dimensions ⇒ Object
-
#initialize(e, params = {}) ⇒ ExceptionPresenter
constructor
A new instance of ExceptionPresenter.
- #reporter ⇒ Object
- #request_data ⇒ Object
Constructor Details
#initialize(e, params = {}) ⇒ ExceptionPresenter
Returns a new instance of ExceptionPresenter.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/errplane/exception_presenter.rb', line 21 def initialize(e, params = {}) e = e.continued_exception if e.respond_to?(:continued_exception) e = e.original_exception if e.respond_to?(:original_exception) @exception = e.is_a?(String) ? Exception.new(e) : e @backtrace = Errplane::Backtrace.new(@exception.backtrace) @params = params[:params] @session_data = params[:session_data] || {} @current_user = params[:current_user] @controller = params[:controller] @action = params[:action] @request_url = params[:request_url] @user_agent = params[:user_agent] @referer = params[:referer] @remote_ip = params[:remote_ip] @custom_data = params[:custom_data] || {} @environment_variables = ENV.to_hash || {} @dimensions = {} end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
14 15 16 |
# File 'lib/errplane/exception_presenter.rb', line 14 def action @action end |
#backtrace ⇒ Object (readonly)
Returns the value of attribute backtrace.
9 10 11 |
# File 'lib/errplane/exception_presenter.rb', line 9 def backtrace @backtrace end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
13 14 15 |
# File 'lib/errplane/exception_presenter.rb', line 13 def controller @controller end |
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
12 13 14 |
# File 'lib/errplane/exception_presenter.rb', line 12 def current_user @current_user end |
#custom_data ⇒ Object (readonly)
Returns the value of attribute custom_data.
19 20 21 |
# File 'lib/errplane/exception_presenter.rb', line 19 def custom_data @custom_data end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
8 9 10 |
# File 'lib/errplane/exception_presenter.rb', line 8 def exception @exception end |
#hash ⇒ Object
Returns the value of attribute hash.
6 7 8 |
# File 'lib/errplane/exception_presenter.rb', line 6 def hash @hash end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
10 11 12 |
# File 'lib/errplane/exception_presenter.rb', line 10 def params @params end |
#referer ⇒ Object (readonly)
Returns the value of attribute referer.
16 17 18 |
# File 'lib/errplane/exception_presenter.rb', line 16 def referer @referer end |
#remote_ip ⇒ Object (readonly)
Returns the value of attribute remote_ip.
17 18 19 |
# File 'lib/errplane/exception_presenter.rb', line 17 def remote_ip @remote_ip end |
#request_url ⇒ Object (readonly)
Returns the value of attribute request_url.
15 16 17 |
# File 'lib/errplane/exception_presenter.rb', line 15 def request_url @request_url end |
#session_data ⇒ Object (readonly)
Returns the value of attribute session_data.
11 12 13 |
# File 'lib/errplane/exception_presenter.rb', line 11 def session_data @session_data end |
#user_agent ⇒ Object (readonly)
Returns the value of attribute user_agent.
18 19 20 |
# File 'lib/errplane/exception_presenter.rb', line 18 def user_agent @user_agent end |
Instance Method Details
#context ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/errplane/exception_presenter.rb', line 41 def context c = { :time => Time.now.utc.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., :backtrace => @backtrace.to_a, :language => "Ruby", :language_version => "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}", :reporter => reporter, :custom_data => @custom_data } c[:environment_variables] = @environment_variables.reject do |k,v| Errplane.configuration.environment_variable_filters.any? { |filter| k =~ filter } end Errplane.configuration.add_custom_exception_data(self) c[:request_data] = request_data if @controller || @action || !@params.blank? c end |
#dimensions ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/errplane/exception_presenter.rb', line 66 def dimensions d = { :class => @exception.class.to_s, :method => "#{@controller}##{@action}", :filename => File.basename(@backtrace.lines.first.try(:file)), :server => Socket.gethostname, :status => "open" }.merge(@dimensions) end |
#reporter ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/errplane/exception_presenter.rb', line 76 def reporter { :name => "Errplane", :version => Errplane::VERSION, :url => "https://github.com/errplane/errplane-ruby" } end |
#request_data ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/errplane/exception_presenter.rb', line 84 def request_data { :params => @params, :session_data => @session_data, :controller => @controller, :action => @action, :request_url => @request_url, :referer => @referer, :remote_ip => @remote_ip, :user_agent => @user_agent } end |