Sha256: 5543d760efe19917a020efb547e49349636f80346d484b99e77cfa34b7770c41
Contents?: true
Size: 1.05 KB
Versions: 15
Compression:
Stored size: 1.05 KB
Contents
module Timber module Events # The exception event is used to track exceptions. # # @note This event should be installed automatically through probes, # such as the {Probes::ActionDispatchDebugExceptions} probe. class Exception < Timber::Event attr_reader :name, :exception_message, :backtrace 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 def to_hash {name: name, message: exception_message, backtrace: backtrace} end alias to_h to_hash def as_json(_options = {}) {:exception => to_hash} end def message message = "#{name} (#{exception_message}):" if backtrace.is_a?(Array) && backtrace.length > 0 message << "\n\n" message << backtrace.join("\n") end message end end end end
Version data entries
15 entries across 15 versions & 2 rubygems