{"record":{"id":"835c7d51053a27ce","repo":"RubyMoney/money","slug":"can-t-add-or-subtract-a-non-zero-value-class-nam","errorCode":null,"errorMessage":"Can't add or subtract a non-zero #{value.class.name} value","messagePattern":"Can't add or subtract a non-zero #(.+?) value","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"lib/money/money/arithmetic.rb","lineNumber":153,"sourceCode":"    #\n    #   @param [Money] other Other +Money+ object to subtract.\n    #   @return [Money]\n    #\n    #   @example\n    #     Money.new(100) - Money.new(99) #=> #<Money @fractional=1>\n    [:+, :-].each do |op|\n      non_zero_message = lambda do |value|\n        \"Can't add or subtract a non-zero #{value.class.name} value\"\n      end\n\n      define_method(op) do |other|\n        case other\n        when Money\n          other = other.exchange_to(currency)\n          new_fractional = fractional.public_send(op, other.fractional)\n          dup_with(fractional: new_fractional)\n        when CoercedNumeric\n          raise TypeError, non_zero_message.call(other.value) unless other.zero?\n\n          dup_with(fractional: other.value.public_send(op, fractional))\n        when Numeric\n          raise TypeError, non_zero_message.call(other) unless other.zero?\n\n          self\n        else\n          raise TypeError, \"Unsupported argument type: #{other.class.name}\"\n        end\n      end\n    end\n\n    # Multiplies the monetary value with the given number and returns a new\n    # +Money+ object with this monetary value and the same currency.\n    #\n    # Note that you can't multiply a Money object by an other +Money+ object.\n    #\n    # @param [Numeric] value Number to multiply by.","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/RubyMoney/money/blob/26e2829c34f165847040a5a40d4d2daa5eb72927/lib/money/money/arithmetic.rb#L135-L171","documentation":"Error \"Can't add or subtract a non-zero #{value.class.name} value\" thrown in RubyMoney/money.","triggerScenarios":"Thrown at lib/money/money/arithmetic.rb:153 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"}