NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages

Every exception extends the abstract RoundlyConsulting\Money\Exceptions\MoneyException (a RuntimeException), so one catch covers the whole family. Messages are developer-facing English; the translatable surface is the validation messages.

use RoundlyConsulting\Money\Exceptions\CurrencyMismatch;
use RoundlyConsulting\Money\Exceptions\MoneyException;

try {
    $total = $cartTotal->add($shippingFee);
} catch (CurrencyMismatch $e) {
    // mixing currencies is a bug, not a conversion
} catch (MoneyException $e) {
    // one catch for the whole family
}
ExceptionThrown when
CurrencyMismatchArithmetic or ordering across currencies; a shared cast column would be re-denominated; a discount, cap, shipping or rate in another currency.
UnknownCurrencyA code the registry does not know.
InvalidCurrencyAn invalid Currency definition; a custom code longer than schema.currency_length.
CurrencyAlreadyRegisteredA duplicate registration without replace; any ISO redefinition.
InvalidAmountMalformed or over-long input, unrecoverable floats, ambiguous parser symbols, tampered payloads.
RoundingNecessaryInput more precise than the target scale, without a rounding mode.
AmountOverflowA result beyond 65 digits; minorInt() outside int64.
DivisionByZeroDividing by zero, or ratioTo() a zero amount.
InvalidAllocationBad allocate(), split() or allocator input.
EmptyMoneyCollectionsum() without a currency, or min(), max(), average() of nothing.
InvalidMoneyValueCast, resource or Blade misuse; corrupt stored data; precision or engine range exceeded.
InvalidPercentageA negative or over-precise percentage.
InvalidRatioA zero denominator, inverting zero, or terms beyond 80 digits.
InvalidDiscountInvalid discounts and discount allocations.
InvalidMoneyConfigurationMisconfiguration, detected at the point of use.
FormatterUnavailableformatting.driver = intl without ext-intl.
ExchangeRateUnavailableNo rate, a stale rate, a future date or a failed chain.
ExchangeRateFetchFailedThe ECB feed could not be read — HTTP error, timeout, malformed or oversized body.
InvalidExchangeRateA non-positive rate, a same-currency rate other than 1, or a rate without an exact decimal of up to 40 characters.

Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

More ways to support, including crypto

By donating, you agree to our donation terms.

Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.