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 probes, such as the Probes::ActionDispatchDebugExceptions probe.
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 |
# 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] 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
21 22 23 |
# File 'lib/timber/events/exception.rb', line 21 def as_json( = {}) {:exception => to_hash} end |
#message ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/timber/events/exception.rb', line 25 def = "#{name} (#{}):" if backtrace.is_a?(Array) && backtrace.length > 0 << "\n\n" << backtrace.join("\n") end end |
#to_hash ⇒ Object Also known as: to_h
16 17 18 |
# File 'lib/timber/events/exception.rb', line 16 def to_hash {name: name, message: , backtrace: backtrace} end |