{"record":{"id":"390f439ec4ee395f","repo":"RubyMoney/money","slug":"no-conversion-rate-known-for-from-currency-iso","errorCode":null,"errorMessage":"No conversion rate known for '#{from.currency.iso_code}' -> '#{to_currency}'","messagePattern":"No conversion rate known for '#(.+?)' -> '#(.+?)'","errorType":"exception","errorClass":"Money::Bank::UnknownRate","httpStatus":null,"severity":"error","filePath":"lib/money/bank/variable_exchange.rb","lineNumber":122,"sourceCode":"      #\n      #   # Exchange 100 USD to CAD:\n      #   bank.exchange_with(c1, \"CAD\") #=> #<Money fractional:12451 currency:CAD>\n      #\n      #   # Exchange 100 CAD to USD:\n      #   bank.exchange_with(c2, \"USD\") #=> #<Money fractional:8031 currency:USD>\n      def exchange_with(from, to_currency, &)\n        to_currency = Currency.wrap(to_currency)\n        if from.currency == to_currency\n          from\n        elsif (rate = get_rate(from.currency, to_currency))\n          fractional = calculate_fractional(from, to_currency)\n          from.dup_with(\n            fractional: exchange(fractional, rate, &),\n            currency: to_currency,\n            bank: self,\n          )\n        else\n          raise UnknownRate, \"No conversion rate known for '#{from.currency.iso_code}' -> '#{to_currency}'\"\n        end\n      end\n\n      def calculate_fractional(from, to_currency)\n        BigDecimal(from.fractional.to_s) / (\n          BigDecimal(from.currency.subunit_to_unit.to_s) /\n          BigDecimal(to_currency.subunit_to_unit.to_s)\n        )\n      end\n\n      def exchange(fractional, rate, &)\n        ex = fractional * BigDecimal(rate.to_s)\n        if block_given?\n          yield ex\n        elsif @rounding_method\n          @rounding_method.call(ex)\n        else\n          ex","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/RubyMoney/money/blob/26e2829c34f165847040a5a40d4d2daa5eb72927/lib/money/bank/variable_exchange.rb#L104-L140","documentation":"Error \"No conversion rate known for '#{from.currency.iso_code}' -> '#{to_currency}'\" thrown in RubyMoney/money.","triggerScenarios":"Thrown at lib/money/bank/variable_exchange.rb:122 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"26e2829c34f165847040a5a40d4d2daa5eb72927","analyzedAt":"2026-08-23T17:41:07.306Z","schemaVersion":2},"datasetVersion":"2026-08-23T21:17:23.414Z"}