Sha256: 81412c779f1661aa6f69d1272c39b953928b77600219f4b93366b6700f113e90
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
require "timber/event" require "timber/util" module Timber module Events # The error event is used to track errors and exceptions. # # @note This event should be installed automatically through integrations, # such as the {Integrations::ActionDispatch::DebugExceptions} integration. class Error < Timber::Event BACKTRACE_JSON_MAX_BYTES = 8192.freeze MESSAGE_MAX_BYTES = 8192.freeze attr_reader :name, :error_message, :backtrace 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 def to_hash @to_hash ||= Util::NonNilHashBuilder.build do |h| h.add(:name, name) h.add(:message, error_message) h.add(:backtrace_json, backtrace, :json_encode => true, :limit => BACKTRACE_JSON_MAX_BYTES) end end alias to_h to_hash # Builds a hash representation containing simple objects, suitable for serialization (JSON). def as_json(_options = {}) {:error => to_hash} end def message "#{name} (#{error_message})" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
timber-2.6.0.pre.beta1 | lib/timber/events/error.rb |