Class: InfluxDB::Rails::ExceptionPresenter
- Inherits:
-
Object
- Object
- InfluxDB::Rails::ExceptionPresenter
- Defined in:
- lib/influxdb/rails/exception_presenter.rb
Overview
rubocop:disable Style/Documentation
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.
-
#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
rubocop:disable Metrics/MethodLength.
- #dimensions ⇒ Object
-
#initialize(ex, params = {}) ⇒ ExceptionPresenter
constructor
A new instance of ExceptionPresenter.
- #request_data ⇒ Object
- #values ⇒ Object
Constructor Details
#initialize(ex, params = {}) ⇒ ExceptionPresenter
Returns a new instance of ExceptionPresenter.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/influxdb/rails/exception_presenter.rb', line 21 def initialize(ex, params = {}) ex = ex.continued_exception if ex.respond_to?(:continued_exception) ex = ex.original_exception if ex.respond_to?(:original_exception) @exception = ex.is_a?(String) ? Exception.new(ex) : ex @backtrace = InfluxDB::Rails::Backtrace.new(@exception.backtrace) @dimensions = {} configure_from_params(params) @environment_variables = ENV.to_hash || {} end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
14 15 16 |
# File 'lib/influxdb/rails/exception_presenter.rb', line 14 def action @action end |
#backtrace ⇒ Object (readonly)
Returns the value of attribute backtrace.
9 10 11 |
# File 'lib/influxdb/rails/exception_presenter.rb', line 9 def backtrace @backtrace end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
13 14 15 |
# File 'lib/influxdb/rails/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/influxdb/rails/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/influxdb/rails/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/influxdb/rails/exception_presenter.rb', line 8 def exception @exception end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
10 11 12 |
# File 'lib/influxdb/rails/exception_presenter.rb', line 10 def params @params end |
#referer ⇒ Object (readonly)
Returns the value of attribute referer.
16 17 18 |
# File 'lib/influxdb/rails/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/influxdb/rails/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/influxdb/rails/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/influxdb/rails/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/influxdb/rails/exception_presenter.rb', line 18 def user_agent @user_agent end |
Instance Method Details
#context ⇒ Object
rubocop:disable Metrics/MethodLength
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/influxdb/rails/exception_presenter.rb', line 33 def context # rubocop:disable Metrics/MethodLength c = { application_name: InfluxDB::Rails.configuration.application_name, application_root: InfluxDB::Rails.configuration.application_root, framework: InfluxDB::Rails.configuration.framework, framework_version: InfluxDB::Rails.configuration.framework_version, language: "Ruby", language_version: "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}", custom_data: @custom_data, } InfluxDB::Rails.configuration.add_custom_exception_data(self) c end |
#dimensions ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/influxdb/rails/exception_presenter.rb', line 48 def dimensions { class: @exception.class.to_s, method: "#{@controller}##{@action}", filename: File.basename(@backtrace.lines.first.try(:file)), server: Socket.gethostname, status: "open", }.merge(@dimensions) end |
#request_data ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/influxdb/rails/exception_presenter.rb', line 65 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 |
#values ⇒ Object
58 59 60 61 62 63 |
# File 'lib/influxdb/rails/exception_presenter.rb', line 58 def values { exception_message: @exception., exception_backtrace: JSON.generate(@backtrace.to_a), } end |