Class: ExceptionHandling::ExceptionInfo
- Inherits:
-
Object
- Object
- ExceptionHandling::ExceptionInfo
- Defined in:
- lib/exception_handling/exception_info.rb
Constant Summary collapse
- ENVIRONMENT_ALLOWLIST =
[ /^HTTP_/, /^QUERY_/, /^REQUEST_/, /^SERVER_/ ].freeze
- ENVIRONMENT_OMIT =
<<~EOS.split("\n") CONTENT_TYPE: application/x-www-form-urlencoded GATEWAY_INTERFACE: CGI/1.2 HTTP_ACCEPT: */* HTTP_ACCEPT: */*, text/javascript, text/html, application/xml, text/xml, */* HTTP_ACCEPT_CHARSET: ISO-8859-1,utf-8;q=0.7,*;q=0.7 HTTP_ACCEPT_ENCODING: gzip, deflate HTTP_ACCEPT_ENCODING: gzip,deflate HTTP_ACCEPT_LANGUAGE: en-us HTTP_CACHE_CONTROL: no-cache HTTP_CONNECTION: Keep-Alive HTTP_HOST: www.invoca.com HTTP_MAX_FORWARDS: 10 HTTP_UA_CPU: x86 HTTP_VERSION: HTTP/1.1 HTTP_X_FORWARDED_HOST: www.invoca.com HTTP_X_FORWARDED_SERVER: www2.invoca.com HTTP_X_REQUESTED_WITH: XMLHttpRequest LANG: PATH: /sbin:/usr/sbin:/bin:/usr/bin PWD: / RAILS_ENV: production RAW_POST_DATA: id=500 REMOTE_ADDR: 10.251.34.225 SCRIPT_NAME: / SERVER_NAME: www.invoca.com SERVER_PORT: 80 SERVER_PROTOCOL: HTTP/1.1 SERVER_SOFTWARE: Mongrel 1.1.4 SHLVL: 1 TERM: linux TERM: xterm-color _: /usr/bin/mongrel_cluster_ctl EOS
- SECTIONS =
[:request, :session, :environment, :backtrace, :event_response].freeze
- HONEYBADGER_CONTEXT_SECTIONS =
[:timestamp, :error_class, :exception_context, :server, :scm_revision, :notes, :user_details, :request, :session, :environment, :backtrace, :event_response, :log_context].freeze
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
-
#exception_context ⇒ Object
readonly
Returns the value of attribute exception_context.
-
#honeybadger_tags ⇒ Object
readonly
Returns the value of attribute honeybadger_tags.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
- #controller_name ⇒ Object
- #data ⇒ Object
- #enhanced_data ⇒ Object
- #exception_description ⇒ Object
- #honeybadger_context_data ⇒ Object
-
#initialize(exception, exception_context, timestamp, controller: nil, data_callback: nil, log_context: nil) ⇒ ExceptionInfo
constructor
A new instance of ExceptionInfo.
- #send_to_honeybadger? ⇒ Boolean
Constructor Details
#initialize(exception, exception_context, timestamp, controller: nil, data_callback: nil, log_context: nil) ⇒ ExceptionInfo
Returns a new instance of ExceptionInfo.
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/exception_handling/exception_info.rb', line 54 def initialize(exception, exception_context, , controller: nil, data_callback: nil, log_context: nil) @exception = exception @exception_context = exception_context @timestamp = @controller = controller || controller_from_context(exception_context) @data_callback = data_callback # merge into the surrounding context just like ContextualLogger does when logging @merged_log_context = ExceptionHandling.logger.current_context_for_thread.deep_merge(log_context || {}) @honeybadger_tags = Array(@merged_log_context[:honeybadger_tags] || []) end |
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
52 53 54 |
# File 'lib/exception_handling/exception_info.rb', line 52 def controller @controller end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
52 53 54 |
# File 'lib/exception_handling/exception_info.rb', line 52 def exception @exception end |
#exception_context ⇒ Object (readonly)
Returns the value of attribute exception_context.
52 53 54 |
# File 'lib/exception_handling/exception_info.rb', line 52 def exception_context @exception_context end |
#honeybadger_tags ⇒ Object (readonly)
Returns the value of attribute honeybadger_tags.
52 53 54 |
# File 'lib/exception_handling/exception_info.rb', line 52 def @honeybadger_tags end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
52 53 54 |
# File 'lib/exception_handling/exception_info.rb', line 52 def @timestamp end |
Instance Method Details
#controller_name ⇒ Object
85 86 87 88 89 90 |
# File 'lib/exception_handling/exception_info.rb', line 85 def controller_name @controller_name ||= ( @merged_log_context[:honeybadger_grouping] || (@controller && @controller.request.parameters.with_indifferent_access[:controller]) ).to_s end |
#data ⇒ Object
65 66 67 |
# File 'lib/exception_handling/exception_info.rb', line 65 def data @data ||= exception_to_data end |
#enhanced_data ⇒ Object
69 70 71 |
# File 'lib/exception_handling/exception_info.rb', line 69 def enhanced_data @enhanced_data ||= exception_to_enhanced_data end |
#exception_description ⇒ Object
73 74 75 |
# File 'lib/exception_handling/exception_info.rb', line 73 def exception_description @exception_description ||= ExceptionHandling.exception_catalog.find(enhanced_data) end |
#honeybadger_context_data ⇒ Object
81 82 83 |
# File 'lib/exception_handling/exception_info.rb', line 81 def honeybadger_context_data @honeybadger_context_data ||= enhanced_data_to_honeybadger_context end |
#send_to_honeybadger? ⇒ Boolean
77 78 79 |
# File 'lib/exception_handling/exception_info.rb', line 77 def send_to_honeybadger? ExceptionHandling.honeybadger_defined? && (!exception_description || exception_description.send_to_honeybadger) end |