Exception: Dry::Types::ConstraintError

Inherits:
TypeError
  • Object
show all
Defined in:
lib/dry/types/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result, input) ⇒ ConstraintError

Returns a new instance of ConstraintError.

Parameters:

  • result (String, #to_s)
  • input (Object)


42
43
44
45
46
47
48
49
50
51
# File 'lib/dry/types/errors.rb', line 42

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)


38
39
40
# File 'lib/dry/types/errors.rb', line 38

def input
  @input
end

#resultString, #to_s (readonly)

Returns:



36
37
38
# File 'lib/dry/types/errors.rb', line 36

def result
  @result
end

Instance Method Details

#to_sString

Returns:

  • (String)


54
55
56
# File 'lib/dry/types/errors.rb', line 54

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