{"record":{"id":"80855387a626c71f","repo":"Humanizr/Humanizer","slug":"unrecognized-number-word-unrecognizedword-808553","errorCode":null,"errorMessage":"Unrecognized number word: {unrecognizedWord}","messagePattern":"Unrecognized number word: (.+?)","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Humanizer/Localisation/WordsToNumber/VigesimalCompoundWordsToNumberConverter.cs","lineNumber":15,"sourceCode":"namespace Humanizer;\n\n/// <summary>\n/// Parses languages that combine base-20 constructions with ordinary scale words.\n/// </summary>\ninternal class VigesimalCompoundWordsToNumberConverter(VigesimalCompoundWordsToNumberProfile profile) : GenderlessWordsToNumberConverter\n{\n    readonly VigesimalCompoundWordsToNumberProfile 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(words, TokenMapNormalizationProfile.LowercaseReplacePeriodsWithSpaces);","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer/Localisation/WordsToNumber/VigesimalCompoundWordsToNumberConverter.cs#L1-L33","documentation":"VigesimalCompoundWordsToNumberConverter.Convert throws this ArgumentException at line 15 when TryConvert cannot parse the phrase under the base-20 + scale grammar. It serves languages combining vigesimal (base-20) constructions with ordinary scale words. Only Convert raises it; the Try overloads return false with the unrecognized token.","triggerScenarios":"Calling ToNumber with tokens outside the locale's vigesimal compound map; foreign words, misspellings, or unsupported ordinals. Fires at line 15 when TryConvert returns false.","commonSituations":"Wrong culture for the phrase; user free text; base-20 forms (e.g. French/Danish-style) the map does not cover; leftover punctuation after normalization.","solutions":["Switch to TryToNumber(words, out var n, culture, out var bad) and handle false.","Use the reported bad token to correct the phrase or culture.","Pre-clean input and confirm the locale matches the phrase's vigesimal grammar."],"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: {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 vigesimal grammar to the phrase.","Inspect the unrecognized token for diagnostics.","Pre-clean input before parsing."],"tags":["words-to-number","vigesimal-compound","argumentexception","parsing","localization"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}