{"record":{"id":"8775bdd6157dbfdd","repo":"RubyMoney/money","slug":"no-exchanging-of-currencies-allowed-from-fro","errorCode":null,"errorMessage":"No exchanging of currencies allowed: #{from} #{from.currency} to #{to_currency}","messagePattern":"No exchanging of currencies allowed: #(.+?) #(.+?) to #(.+?)","errorType":"exception","errorClass":"Money::Bank::DifferentCurrencyError","httpStatus":null,"severity":"error","filePath":"lib/money/bank/single_currency.rb","lineNumber":21,"sourceCode":"require \"money/bank/base\"\n\nclass Money\n  module Bank\n    # Raised when trying to exchange currencies\n    class DifferentCurrencyError < Error; end\n\n    # Class to ensure client code is operating in a single currency\n    # by raising if an exchange attempts to happen.\n    #\n    # This is useful when an application uses multiple currencies but\n    # it usually deals with only one currency at a time so any arithmetic\n    # where exchanges happen are erroneous. Using this as the default bank\n    # means that that these mistakes don't silently do the wrong thing.\n    class SingleCurrency < Base\n      # Raises a DifferentCurrencyError to remove possibility of accidentally\n      # exchanging currencies\n      def exchange_with(from, to_currency, &)\n        raise DifferentCurrencyError, \"No exchanging of currencies allowed: #{from} #{from.currency} to #{to_currency}\"\n      end\n    end\n  end\nend\n","sourceCodeStart":3,"sourceCodeEnd":26,"githubUrl":"https://github.com/RubyMoney/money/blob/26e2829c34f165847040a5a40d4d2daa5eb72927/lib/money/bank/single_currency.rb#L3-L26","documentation":"Error \"No exchanging of currencies allowed: #{from} #{from.currency} to #{to_currency}\" thrown in RubyMoney/money.","triggerScenarios":"Thrown at lib/money/bank/single_currency.rb:21 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"}