class

Unit::ValidationError

Inherits Unit::UnitError < Exception < Reference < Object

Exception raised when a validation constraint is violated. This can happen when values are outside acceptable ranges or when business rules are violated.

Example:

begin
  # If negative weights are not allowed:
  Weight.new(-5, :kg)
rescue ex : Unit::ValidationError
  puts ex.message # => "Weight cannot be negative"
end

Constructors

new(message : String)
Source