Class: Timber::Events::Error
- Inherits:
-
Timber::Event
- Object
- Timber::Event
- Timber::Events::Error
- Defined in:
- lib/timber/events/error.rb
Overview
Note:
This event should be installed automatically through integrations, such as the Integrations::ActionDispatch::DebugExceptions integration.
The error event is used to track errors and exceptions.
Direct Known Subclasses
Constant Summary collapse
- MAX_MESSAGE_BYTES =
8192.freeze
Instance Attribute Summary collapse
-
#backtrace ⇒ Object
readonly
Returns the value of attribute backtrace.
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#as_json(_options = {}) ⇒ Object
Builds a hash representation containing simple objects, suitable for serialization (JSON).
-
#initialize(attributes) ⇒ Error
constructor
A new instance of Error.
- #message ⇒ Object
- #to_hash ⇒ Object (also: #to_h)
Constructor Details
#initialize(attributes) ⇒ Error
Returns a new instance of Error.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/timber/events/error.rb', line 15 def initialize(attributes) @name = attributes[:name] || raise(ArgumentError.new(":name is required")) = attributes[:error_message] || raise(ArgumentError.new(":error_message is required")) = .byteslice(0, MAX_MESSAGE_BYTES) backtrace = attributes[:backtrace] if !backtrace.nil? && backtrace != [] @backtrace = backtrace[0..9].collect { |line| parse_backtrace_line(line) } end end |
Instance Attribute Details
#backtrace ⇒ Object (readonly)
Returns the value of attribute backtrace.
13 14 15 |
# File 'lib/timber/events/error.rb', line 13 def backtrace @backtrace end |
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
13 14 15 |
# File 'lib/timber/events/error.rb', line 13 def end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/timber/events/error.rb', line 13 def name @name end |
Instance Method Details
#as_json(_options = {}) ⇒ Object
Builds a hash representation containing simple objects, suitable for serialization (JSON).
33 34 35 |
# File 'lib/timber/events/error.rb', line 33 def as_json( = {}) {:error => to_hash} end |
#message ⇒ Object
37 38 39 |
# File 'lib/timber/events/error.rb', line 37 def "#{name} (#{error_message})" end |
#to_hash ⇒ Object Also known as: to_h
27 28 29 |
# File 'lib/timber/events/error.rb', line 27 def to_hash {name: name, message: , backtrace: backtrace} end |