{"record":{"id":"17d5c604437cb201","repo":"Humanizr/Humanizer","slug":"the-configured-profile-supports-magnitudes-through","errorCode":null,"errorMessage":"The configured profile supports magnitudes through {maximumMagnitude}.","messagePattern":"The configured profile supports magnitudes through (.+?)\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Humanizer/Localisation/NumberToWords/JoinedScaleNumberToWordsConverter.cs","lineNumber":27,"sourceCode":"/// largest value to the smallest and joins the resulting fragments with the generated separator\n/// rules.\n/// </remarks>\nclass JoinedScaleNumberToWordsConverter(JoinedScaleNumberToWordsProfile profile) : GenderedNumberToWordsConverter\n{\n    readonly JoinedScaleNumberToWordsProfile profile = profile;\n\n    /// <inheritdoc/>\n    public override string Convert(long number, GrammaticalGender gender, bool addAnd = true)\n    {\n        // `long.MinValue` is represented as one extra magnitude slot when the profile explicitly\n        // allows it; everything else is bounded by the generated profile's declared ceiling.\n        var magnitude = number == long.MinValue\n            ? (ulong)long.MaxValue + 1\n            : (ulong)Math.Abs(number);\n        var maximumMagnitude = (ulong)profile.MaximumValue + (profile.AllowLongMinValue ? 1UL : 0UL);\n        if (magnitude > maximumMagnitude)\n        {\n            throw new ArgumentOutOfRangeException(nameof(number), number, $\"The configured profile supports magnitudes through {maximumMagnitude}.\");\n        }\n\n        if (number == 0)\n        {\n            return profile.ZeroWord;\n        }\n\n        if (number < 0)\n        {\n            return $\"{profile.MinusWord}{profile.NegativeJoinWord}{ConvertNonNegative(magnitude, gender)}\";\n        }\n\n        return ConvertNonNegative((ulong)number, gender);\n    }\n\n    /// <summary>\n    /// Converts the non-negative portion of a value after magnitude validation.\n    /// </summary>","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer/Localisation/NumberToWords/JoinedScaleNumberToWordsConverter.cs#L9-L45","documentation":"Gendered joined-scale locales declare a MaximumValue (optionally +1 when AllowLongMinValue is set, so long.MinValue is representable). Magnitudes above that ceiling throw ArgumentOutOfRangeException at the top of Convert. The ceiling reflects how high the locale's scale table reaches.","triggerScenarios":"value.ToWords(gender, new CultureInfo(<joined-scale culture>)) or value.ToWords(<culture>) where the absolute magnitude exceeds profile.MaximumValue (+1 if AllowLongMinValue).","commonSituations":"Converting very large longs (IDs, byte counts) under a locale whose authored scales stop at millions or billions.","solutions":["Route out-of-range values to a culture with a higher ceiling (e.g. invariant/English).","Clamp or reject oversized inputs in your own layer.","Contribute higher scales to the locale profile to raise MaximumValue."],"exampleFix":"// before\nvar w = value.ToWords(GrammaticalGender.Masculine, ci);\n\n// after — fall back for oversized values (MaximumValue is not public, so wrap defensively)\nstring w;\ntry\n{\n    w = value.ToWords(GrammaticalGender.Masculine, ci);\n}\ncatch (ArgumentOutOfRangeException)\n{\n    w = value.ToWords(CultureInfo.InvariantCulture);\n}","handlingStrategy":"try-catch","validationCode":"// MaximumValue is not public, so a direct pre-check is unavailable. For joined-scale gendered\n// locales, wrap the call and fall back on ArgumentOutOfRangeException.","typeGuard":null,"tryCatchPattern":"string words;\ntry\n{\n    words = value.ToWords(gender, ci);\n}\ncatch (ArgumentOutOfRangeException)\n{\n    words = value.ToWords(CultureInfo.InvariantCulture);\n}","preventionTips":["Record each joined-scale locale's effective ceiling from locale docs/tests.","Bound user-facing numeric inputs before localizing them.","Fall back to a high-ceiling culture for values likely to exceed authored scales."],"tags":["number-to-words","localization","range-check"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}