class

Unit::ArithmeticError

Inherits Unit::UnitError < Exception < Reference < Object

Exception raised when arithmetic operations fail. This includes operations like adding incompatible units, division by zero, or other arithmetic constraints.

Example:

begin
  weight = Weight.new(10, :kg)
  weight / 0
rescue ex : Unit::ArithmeticError
  puts ex.message # => "Arithmetic operation 'division' failed: Division by zero"
end

Constructors

new(operation : String, reason : String)
Source

Class methods

division_by_zero

Factory method for division by zero errors

Source
incompatible_operands(operation : String, left_type : String, right_type : String)

Factory method for incompatible operand errors

Source

Instance methods

operation
Source
reason
Source