Exception: Dry::Types::CoercionError
- Inherits:
-
StandardError
- Object
- StandardError
- Dry::Types::CoercionError
- Defined in:
- lib/dry/types/errors.rb
Overview
Base class for coercion errors raise by dry-types
Direct Known Subclasses
Instance Attribute Summary collapse
-
#meta ⇒ Object
readonly
Metadata associated with the error.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(message, meta: Undefined, backtrace: Undefined) ⇒ CoercionError
constructor
private
A new instance of CoercionError.
Constructor Details
#initialize(message, meta: Undefined, backtrace: Undefined) ⇒ CoercionError
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of CoercionError.
35 36 37 38 39 40 41 42 43 |
# File 'lib/dry/types/errors.rb', line 35 def initialize(, meta: Undefined, backtrace: Undefined) unless .is_a?(::String) raise ::ArgumentError, "message must be a string, #{.class} given" end super() @meta = Undefined.default(, nil) set_backtrace(backtrace) unless Undefined.equal?(backtrace) end |
Instance Attribute Details
#meta ⇒ Object (readonly)
Metadata associated with the error
32 33 34 |
# File 'lib/dry/types/errors.rb', line 32 def @meta end |
Class Method Details
.handle(exception, meta: Undefined) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/dry/types/errors.rb', line 17 def self.handle(exception, meta: Undefined) if block_given? yield else raise new( exception., meta: , backtrace: exception.backtrace ) end end |