Sha256: 5a42aec82cd374cfdd1debda1b47d66afa017f3cbbfb15ff3f30605129aa0c22

Contents?: true

Size: 812 Bytes

Versions: 83

Compression:

Stored size: 812 Bytes

Contents

# Datadog global namespace
module Datadog
  # Error is a value-object responsible for sanitizing/encapsulating error data
  class Error
    attr_reader :type, :message, :backtrace

    def self.build_from(value)
      case value
      when Error then value
      when Array then new(*value)
      when Exception then new(value.class, value.message, value.backtrace)
      when ContainsMessage then new(value.class, value.message)
      else BlankError
      end
    end

    def initialize(type = nil, message = nil, backtrace = nil)
      backtrace = Array(backtrace).join("\n")
      @type = Utils.utf8_encode(type)
      @message = Utils.utf8_encode(message)
      @backtrace = Utils.utf8_encode(backtrace)
    end

    BlankError = Error.new
    ContainsMessage = ->(v) { v.respond_to?(:message) }
  end
end

Version data entries

83 entries across 83 versions & 2 rubygems

Version Path
ddtrace-0.47.0 lib/ddtrace/error.rb
ddtrace-0.46.0 lib/ddtrace/error.rb
ddtrace-0.45.0 lib/ddtrace/error.rb
ddtrace-0.44.0 lib/ddtrace/error.rb
ddtrace-0.43.0 lib/ddtrace/error.rb
ddtrace-0.42.0 lib/ddtrace/error.rb
ddtrace-0.41.0 lib/ddtrace/error.rb
ls-trace-0.2.0 lib/ddtrace/error.rb
ddtrace-0.40.0 lib/ddtrace/error.rb
ddtrace-0.39.0 lib/ddtrace/error.rb
ddtrace-0.38.0 lib/ddtrace/error.rb
ddtrace-0.37.0 lib/ddtrace/error.rb
ddtrace-0.36.0 lib/ddtrace/error.rb
ls-trace-0.1.2 lib/ddtrace/error.rb
ddtrace-0.35.2 lib/ddtrace/error.rb
ddtrace-0.35.1 lib/ddtrace/error.rb
ddtrace-0.35.0 lib/ddtrace/error.rb
ddtrace-0.34.2 lib/ddtrace/error.rb
ddtrace-0.34.1 lib/ddtrace/error.rb
ddtrace-0.34.0 lib/ddtrace/error.rb