Exception: Dry::Types::ConstraintError

Inherits:
CoercionError show all
Defined in:
lib/dry/types/errors.rb

Instance Attribute Summary collapse

Attributes inherited from CoercionError

#meta

Instance Method Summary collapse

Methods inherited from CoercionError

handle

Constructor Details

#initialize(result, input) ⇒ ConstraintError

Returns a new instance of ConstraintError.

Parameters:

  • result (String, #to_s)
  • input (Object)
[View source]

120
121
122
123
124
125
126
127
128
129
# File 'lib/dry/types/errors.rb', line 120

def initialize(result, input)
  @result = result
  @input = input

  if result.is_a?(::String)
    super(result)
  else
    super(to_s)
  end
end

Instance Attribute Details

#inputObject (readonly)

Returns:

  • (Object)

116
117
118
# File 'lib/dry/types/errors.rb', line 116

def input
  @input
end

#resultString, #to_s (readonly)

Returns:


114
115
116
# File 'lib/dry/types/errors.rb', line 114

def result
  @result
end

Instance Method Details

#messageString Also known as: to_s

Returns:

  • (String)
[View source]

132
133
134
# File 'lib/dry/types/errors.rb', line 132

def message
  "#{input.inspect} violates constraints (#{result} failed)"
end