{"record":{"id":"57dff85b4f80119b","repo":"Humanizr/Humanizer","slug":"unrecognized-number-word-unrecognizedword-57dff8","errorCode":null,"errorMessage":"Unrecognized number word: {unrecognizedWord}","messagePattern":"Unrecognized number word: (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Humanizer/Localisation/WordsToNumber/PrefixedTensScaleWordsToNumberConverter.cs","lineNumber":17,"sourceCode":"namespace Humanizer;\n\n/// <summary>\n/// Parses languages that attach scale words and tens stems as prefixes inside a glued compound.\n/// </summary>\ninternal class PrefixedTensScaleWordsToNumberConverter(PrefixedTensScaleWordsToNumberProfile profile) : GenderlessWordsToNumberConverter\n{\n    const int MaximumParseDepth = 128;\n\n    readonly PrefixedTensScaleWordsToNumberProfile 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            throw new ArgumentException(\"Input words cannot be empty.\");\n        }\n\n        var normalized = Normalize(words);","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer/Localisation/WordsToNumber/PrefixedTensScaleWordsToNumberConverter.cs#L1-L35","documentation":"PrefixedTensScaleWordsToNumberConverter.Convert throws this ArgumentException at line 17 when TryConvert fails, surfacing the first token it could not map under the prefixed-tens-scale grammar. Only the throwing Convert path raises it; the Try overloads return false with the unrecognized token. This converter caps recursion at MaximumParseDepth (128).","triggerScenarios":"Calling ToNumber with a phrase whose tokens are outside the locale's prefixed-tens-scale cardinal map, e.g. foreign words, misspellings, ordinals, or tokens exceeding the 128-depth parse limit. Fires at line 17 when TryConvert returns false.","commonSituations":"Wrong culture for the phrase's language; user free text; very long or pathological inputs hitting the parse-depth cap; tokens with punctuation the normalizer leaves behind.","solutions":["Replace ToNumber with TryToNumber(words, out var n, culture, out var bad) and handle false.","Use the reported bad token to correct the input or pick the right culture.","Shorten or rephrase very long inputs to stay within the parse-depth limit.","Confirm the locale matches the phrase's grammar family."],"exampleFix":"// before\nvar n = phrase.ToNumber(culture);\n// after\nif (phrase.TryToNumber(out var n, culture, out var bad))\n    Use(n);\nelse\n    Log($\"could not parse near '{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 culture to phrase language.","Avoid extremely long phrases that may hit the 128-depth parse cap.","Pre-clean input before parsing."],"tags":["words-to-number","prefixed-tens-scale","argumentexception","parsing","localization"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}