Sha256: 4cf1108498e09972695da6664a84cec00acd93214b5df23539ef391f101c3aa2

Contents?: true

Size: 778 Bytes

Versions: 2

Compression:

Stored size: 778 Bytes

Contents

require "timber/util"
require "timber/event"

module Timber
  module Events
    # @private
    class Error < Timber::Event
      attr_reader :name, :error_message, :backtrace_json

      def initialize(attributes)
        @name = attributes[:name]
        @error_message = attributes[:error_message]

        if attributes[:backtrace]
          @backtrace_json = attributes[:backtrace].to_json
        end
      end

      def message
        message = "#{name}"

        if !error_message.nil?
          message << " (#{error_message})"
        end

        message
      end

      def to_hash
        {
          error: {
            name: name,
            message: error_message,
            backtrace_json: backtrace_json
          }
        }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
timber-3.0.1 lib/timber/events/error.rb
timber-3.0.0 lib/timber/events/error.rb