Class: Datadog::Core::Error
- Inherits:
-
Object
- Object
- Datadog::Core::Error
- Defined in:
- lib/datadog/core/error.rb
Overview
Error is a value-object responsible for sanitizing/encapsulating error data
Instance Attribute Summary collapse
-
#backtrace ⇒ Object
readonly
Returns the value of attribute backtrace.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type = nil, message = nil, backtrace = nil) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(type = nil, message = nil, backtrace = nil) ⇒ Error
Returns a new instance of Error.
93 94 95 96 97 98 99 |
# File 'lib/datadog/core/error.rb', line 93 def initialize(type = nil, = nil, backtrace = nil) backtrace = Array(backtrace).join("\n") unless backtrace.is_a?(String) @type = Utils.utf8_encode(type) @message = Utils.utf8_encode() @backtrace = Utils.utf8_encode(backtrace) end |
Instance Attribute Details
#backtrace ⇒ Object (readonly)
Returns the value of attribute backtrace.
9 10 11 |
# File 'lib/datadog/core/error.rb', line 9 def backtrace @backtrace end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
9 10 11 |
# File 'lib/datadog/core/error.rb', line 9 def @message end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/datadog/core/error.rb', line 9 def type @type end |
Class Method Details
.build_from(value) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/datadog/core/error.rb', line 12 def build_from(value) case value # A Ruby {Exception} is the most common parameter type. when Exception then new(value.class, value., full_backtrace(value)) # steep:ignore:start # Steep doesn't like an array with up to 3 elements to be passed here: it thinks the array is unbounded. when Array then new(*value) # Steep can not follow the logic inside the lambda, thus it doesn't know `value` responds to `:message`. when ->(v) { v.respond_to?(:message) } then new(value.class, value.) # steep:ignore:end when String then new(nil, value) when Error then value else Error.new # Blank error end end |