Class: Datadog::Error
- Inherits:
-
Object
- Object
- Datadog::Error
- Defined in:
- lib/ddtrace/error.rb
Overview
Error is a value-object responsible for sanitizing/encapsulating error data
Constant Summary collapse
- BlankError =
Error.new
- ContainsMessage =
->(v) { v.respond_to?(:message) }
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.
17 18 19 20 21 22 |
# File 'lib/ddtrace/error.rb', line 17 def initialize(type = nil, = nil, backtrace = nil) backtrace = Array(backtrace).join("\n") @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.
5 6 7 |
# File 'lib/ddtrace/error.rb', line 5 def backtrace @backtrace end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
5 6 7 |
# File 'lib/ddtrace/error.rb', line 5 def @message end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/ddtrace/error.rb', line 5 def type @type end |
Class Method Details
.build_from(value) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/ddtrace/error.rb', line 7 def self.build_from(value) case value when Error then value when Array then new(*value) when Exception then new(value.class, value., value.backtrace) when ContainsMessage then new(value.class, value.) else BlankError end end |