Amount#/ at lib/zold/amount.rb:119-122 accepts any Integer or Float divisor but performs no further validation before dividing. Dividing by 0 raises ZeroDivisionError (or FloatDomainError for 0.0, since (@zents / 0.0).to_i evaluates Infinity.to_i), and the call site sees a generic standard-library exception instead of the descriptive RuntimeError that every other binary operator in this class raises (+, -, *, ==, <, >, <=, <=>).
There is also no overflow guard symmetrical to the one in #*. Dividing by a positive Float less than 1.0 can produce a zent count beyond MAX, and the result is only caught indirectly by Amount.new(zents: ...) raising "The amount is too big". The error then references the result, not the operation.
Fix on lib/zold/amount.rb:119: add raise 'Cannot divide by zero' if other.zero? and the same > MAX / < -MAX overflow check that the multiplication path needs. Aligning the contract across * and / keeps callers like Tax#debt from converting one library's exception into another.
Amount#/atlib/zold/amount.rb:119-122accepts anyIntegerorFloatdivisor but performs no further validation before dividing. Dividing by0raisesZeroDivisionError(orFloatDomainErrorfor0.0, since(@zents / 0.0).to_ievaluatesInfinity.to_i), and the call site sees a generic standard-library exception instead of the descriptiveRuntimeErrorthat every other binary operator in this class raises (+,-,*,==,<,>,<=,<=>).There is also no overflow guard symmetrical to the one in
#*. Dividing by a positiveFloatless than1.0can produce a zent count beyondMAX, and the result is only caught indirectly byAmount.new(zents: ...)raising "The amount is too big". The error then references the result, not the operation.Fix on
lib/zold/amount.rb:119: addraise 'Cannot divide by zero' if other.zero?and the same> MAX/< -MAXoverflow check that the multiplication path needs. Aligning the contract across*and/keeps callers likeTax#debtfrom converting one library's exception into another.