Class: Timber::Events::Exception
- Inherits:
-
Timber::Event
- Object
- Timber::Event
- Timber::Events::Exception
- Defined in:
- lib/timber/events/exception.rb
Overview
Note:
This event should be installed automatically through integrations, such as the Integrations::ActionDispatch::DebugExceptions integration.
The exception event is used to track exceptions.
Instance Attribute Summary collapse
-
#backtrace ⇒ Object
readonly
Returns the value of attribute backtrace.
-
#exception_message ⇒ Object
readonly
Returns the value of attribute exception_message.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #as_json(_options = {}) ⇒ Object
-
#initialize(attributes) ⇒ Exception
constructor
A new instance of Exception.
- #message ⇒ Object
- #to_hash ⇒ Object (also: #to_h)
Constructor Details
#initialize(attributes) ⇒ Exception
Returns a new instance of Exception.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/timber/events/exception.rb', line 10 def initialize(attributes) @name = attributes[:name] || raise(ArgumentError.new(":name is required")) @exception_message = attributes[:exception_message] || raise(ArgumentError.new(":exception_message is required")) backtrace = attributes[:backtrace] if backtrace.nil? || backtrace == [] raise(ArgumentError.new(":backtrace is required")) end # 10 items max @backtrace = backtrace[0..9].collect { |line| parse_backtrace_line(line) } end |
Instance Attribute Details
#backtrace ⇒ Object (readonly)
Returns the value of attribute backtrace.
8 9 10 |
# File 'lib/timber/events/exception.rb', line 8 def backtrace @backtrace end |
#exception_message ⇒ Object (readonly)
Returns the value of attribute exception_message.
8 9 10 |
# File 'lib/timber/events/exception.rb', line 8 def @exception_message end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/timber/events/exception.rb', line 8 def name @name end |
Instance Method Details
#as_json(_options = {}) ⇒ Object
28 29 30 |
# File 'lib/timber/events/exception.rb', line 28 def as_json( = {}) {:server_side_app => {:exception => to_hash}} end |
#message ⇒ Object
32 33 34 |
# File 'lib/timber/events/exception.rb', line 32 def "#{name} (#{})" end |
#to_hash ⇒ Object Also known as: to_h
23 24 25 |
# File 'lib/timber/events/exception.rb', line 23 def to_hash {name: name, message: , backtrace: backtrace} end |