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
- BACKTRACE_JSON_MAX_BYTES =
8192.freeze
- MESSAGE_MAX_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.
16 17 18 19 20 21 |
# File 'lib/timber/events/error.rb', line 16 def initialize(attributes) normalizer = Util::AttributeNormalizer.new(attributes) @name = normalizer.fetch!(:name, :string) @error_message = normalizer.fetch(:error_message, :string, :limit => MESSAGE_MAX_BYTES) @backtrace = normalizer.fetch(:backtrace, :array) end |
Instance Attribute Details
#backtrace ⇒ Object (readonly)
Returns the value of attribute backtrace.
14 15 16 |
# File 'lib/timber/events/error.rb', line 14 def backtrace @backtrace end |
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
14 15 16 |
# File 'lib/timber/events/error.rb', line 14 def @error_message end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/timber/events/error.rb', line 14 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 40 41 42 43 44 45 |
# File 'lib/timber/events/error.rb', line 37 def = "#{name}" if !.nil? << " (#{})" end end |
#to_hash ⇒ Object Also known as: to_h
23 24 25 26 27 28 29 |
# File 'lib/timber/events/error.rb', line 23 def to_hash @to_hash ||= Util::NonNilHashBuilder.build do |h| h.add(:name, name) h.add(:message, ) h.add(:backtrace_json, backtrace, :json_encode => true, :limit => BACKTRACE_JSON_MAX_BYTES) end end |