{"record":{"id":"10793a4401865b48","repo":"Humanizr/Humanizer","slug":"unrecognized-number-word-unrecognizedword-10793a","errorCode":null,"errorMessage":"Unrecognized number word: {unrecognizedWord}","messagePattern":"Unrecognized number word: (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Humanizer/Localisation/WordsToNumber/ScaleLeadingCompoundWordsToNumberConverter.cs","lineNumber":15,"sourceCode":"namespace Humanizer;\n\n/// <summary>\n/// Parses decimal number words whose scale nouns precede their count words.\n/// </summary>\ninternal class ScaleLeadingCompoundWordsToNumberConverter(ScaleLeadingCompoundWordsToNumberProfile profile) : GenderlessWordsToNumberConverter\n{\n    readonly ScaleLeadingCompoundWordsToNumberProfile profile = profile;\n\n    /// <inheritdoc />\n    public override long Convert(string words)\n    {\n        if (!TryConvert(words, out var parsedValue, out var unrecognizedWord))\n        {\n            throw new ArgumentException($\"Unrecognized number word: {unrecognizedWord}\");\n        }\n\n        return parsedValue;\n    }\n\n    /// <inheritdoc />\n    public override bool TryConvert(string words, out long parsedValue) =>\n        TryConvert(words, out parsedValue, out _);\n\n    /// <inheritdoc />\n    public override bool TryConvert(string words, out long parsedValue, out string? unrecognizedWord)\n    {\n        if (string.IsNullOrWhiteSpace(words))\n        {\n            parsedValue = default;\n            unrecognizedWord = words ?? string.Empty;\n            return false;\n        }","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer/Localisation/WordsToNumber/ScaleLeadingCompoundWordsToNumberConverter.cs#L1-L33","documentation":"ScaleLeadingCompoundWordsToNumberConverter.Convert throws this ArgumentException at line 15 when TryConvert cannot parse the phrase under the scale-leading grammar (where scale nouns precede count words). Only Convert raises it; the Try overloads return false with the unrecognized token.","triggerScenarios":"Calling ToNumber with tokens outside the locale's scale-leading cardinal/ordinal map, malformed compounds, or foreign words. Fires at line 15 when TryConvert returns false.","commonSituations":"Wrong culture for the phrase; user free text; ordinal phrases unsupported by the grammar; tokens left over after tokenization.","solutions":["Use TryToNumber(words, out var n, culture, out var bad) instead of ToNumber.","Inspect bad to find and correct the offending token.","Verify the culture's grammar family matches the phrase.","Clean the input (trim, normalize spaces) before parsing."],"exampleFix":"// before\nvar n = phrase.ToNumber(culture);\n// after\nif (phrase.TryToNumber(out var n, culture, out var bad))\n    Use(n);\nelse\n    Warn($\"unrecognized token: {bad}\");","handlingStrategy":"validation","validationCode":"if (!words.TryToNumber(out var n, culture, out var unrecognized))\n    return Result.Fail($\"unrecognized token: {unrecognized}\");\nreturn Result.Ok(n);","typeGuard":null,"tryCatchPattern":"try { var n = words.ToNumber(culture); }\ncatch (ArgumentException ex) when (ex.Message.StartsWith(\"Unrecognized number word\"))\n    { /* handle */ }","preventionTips":["Use TryToNumber for untrusted input.","Match the culture's scale-leading grammar to the phrase.","Inspect the unrecognized token for diagnostics.","Clean input before parsing."],"tags":["words-to-number","scale-leading-compound","argumentexception","parsing","localization"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}