{"record":{"id":"0c6565aee778fec9","repo":"Humanizr/Humanizer","slug":"unrecognized-number-word-unrecognizedword-0c6565","errorCode":null,"errorMessage":"Unrecognized number word: {unrecognizedWord}","messagePattern":"Unrecognized number word: (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Humanizer/Localisation/WordsToNumber/LinkingAffixWordsToNumberConverter.cs","lineNumber":16,"sourceCode":"namespace Humanizer;\n\n/// <summary>\n/// Parses languages that use linking affixes inside compounds, such as embedded teen stems or\n/// joined suffixes on cardinal tokens.\n/// </summary>\ninternal class LinkingAffixWordsToNumberConverter(LinkingAffixWordsToNumberProfile profile) : GenderlessWordsToNumberConverter\n{\n    readonly LinkingAffixWordsToNumberProfile 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 = TokenMapWordsToNumberNormalizer.Normalize(","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer/Localisation/WordsToNumber/LinkingAffixWordsToNumberConverter.cs#L1-L34","documentation":"LinkingAffixWordsToNumberConverter.Convert throws this ArgumentException after TryConvert reports the first token it could not map. It serves languages whose compounds embed teen stems or joined cardinal suffixes, so a token outside the locale's cardinal/linked-suffix map is unrecoverable. Only the throwing Convert path raises it; TryConvert returns false with the offending token in the out parameter.","triggerScenarios":"Calling ToNumber(words, culture) (or the converter's Convert) with a phrase whose normalized tokens are not in the locale's linking-affix cardinal map, e.g. a misspelled word, a number from a different locale, or stray punctuation the normalizer does not strip. The throw is produced at line 16 when TryConvert returns false.","commonSituations":"User-typed free text passed straight into ToNumber; a locale mismatch where English words are parsed under a linking-affix locale (or vice versa); copy-paste with smart quotes or extra tokens; an ordinal/decimal phrase fed to the integer converter.","solutions":["Switch from ToNumber to TryToNumber(words, out var n, culture, out var unrecognized) and handle the false return.","Inspect the reported unrecognizedWord to find the misspelled or foreign token and correct the input.","Confirm the CultureInfo passed matches the language of the phrase (registry falls back to English for unsupported locales).","Pre-clean input (trim, collapse spaces, replace typographic quotes) before parsing."],"exampleFix":"// before\nvar n = \"twenty banana\".ToNumber(CultureInfo.GetCultureInfo(\"en\"));\n// after\nif (\"twenty banana\".TryToNumber(out var n, CultureInfo.GetCultureInfo(\"en\"), out var bad))\n    Console.WriteLine(n);\nelse\n    Console.WriteLine($\"bad token: {bad}\");","handlingStrategy":"validation","validationCode":"// Use the non-throwing overload; it reports the first bad token.\nif (!words.TryToNumber(out var n, culture, out var unrecognized))\n    return Result.Fail($\"unrecognized token: {unrecognized}\");\nreturn Result.Ok(n);","typeGuard":null,"tryCatchPattern":"// Only if you must call ToNumber:\ntry { var n = words.ToNumber(culture); }\ncatch (ArgumentException ex) when (ex.Message.StartsWith(\"Unrecognized number word\"))\n    { /* handle unknown token */ }","preventionTips":["Prefer TryToNumber over ToNumber for any untrusted input.","Match the CultureInfo to the phrase's language.","Trim and normalize input (collapse spaces, replace typographic quotes) before parsing.","Inspect the unrecognizedWord out parameter for diagnostics."],"tags":["words-to-number","linking-affix","argumentexception","parsing","localization"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}