RubyMoney/money · error · ArgumentError
must be initialized with a finite value
Error message
must be initialized with a finite value
What it means
Error "must be initialized with a finite value" thrown in RubyMoney/money.
Source
Thrown at lib/money/money.rb:370
# @example
# Money.new(100) #=> #<Money @fractional=100 @currency="USD">
# Money.new(100, "USD") #=> #<Money @fractional=100 @currency="USD">
# Money.new(100, "EUR") #=> #<Money @fractional=100 @currency="EUR">
#
def initialize(obj, currency = nil, options = {})
# For backwards compatibility, if options is not a Hash, treat it as a bank parameter
unless options.is_a?(Hash)
options = { bank: options }
end
@fractional = as_d(obj.respond_to?(:fractional) ? obj.fractional : obj)
@currency = obj.respond_to?(:currency) ? obj.currency : Currency.wrap(currency)
@currency ||= Money.default_currency
@bank = obj.respond_to?(:bank) ? obj.bank : options[:bank]
@bank ||= Money.default_bank
# BigDecimal can be Infinity and NaN, money of that amount does not make sense
raise ArgumentError, "must be initialized with a finite value" unless @fractional.finite?
raise Currency::NoCurrency, "must provide a currency" if @currency.nil?
end
# DEPRECATED.
#
# @see #amount
def dollars
warn "[DEPRECATION] `Money#dollars` is deprecated in favor of " \
"`Money#amount`."
amount
end
# Returns the numerical value of the money.
#
# @return [BigDecimal]
#
# @exampleView on GitHub (pinned to 26e2829c34)
When it happens
Trigger: Thrown at lib/money/money.rb:370 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of RubyMoney/money@26e2829c34 (2026-08-23).
Data as JSON: /api/errors/886c5d7772732030.
Report an issue: GitHub.