Humanizr/Humanizer · error · InvalidOperationException

Linked-vigesimal number profiles require a lexical word tabl

Error message

Linked-vigesimal number profiles require a lexical word table or scale row covering the requested value.

What it means

ConvertPositive produced no scale parts and the value exceeded the lexicalized Words table — no scale row and no word covered it. The guard prevents emitting an empty or garbage string. Indicates the profile's scales don't reach the requested magnitude for this linked-vigesimal locale.

Source

Thrown at src/Humanizer/Localisation/NumberToWords/LinkedVigesimalNumberToWordsConverter.cs:78

        var parts = new List<string>();
        var remainder = number;
        foreach (var scale in profile.Scales)
        {
            var scaleValue = (ulong)scale.Value;
            var count = remainder / scaleValue;
            if (count == 0)
            {
                continue;
            }

            remainder %= scaleValue;
            parts.Add(FormatScale(count, scale, remainder > 0));
        }

        if (parts.Count == 0)
        {
            throw new InvalidOperationException("Linked-vigesimal number profiles require a lexical word table or scale row covering the requested value.");
        }

        if (remainder > 0)
        {
            var renderedRemainder = ConvertPositive(remainder);
            if (remainder < (ulong)profile.TerminalRemainderThreshold)
            {
                parts.Add(profile.GetTerminalRemainderJoiner(renderedRemainder));
            }

            parts.Add(renderedRemainder);
        }

        return string.Join(profile.PartJoiner, parts);
    }

    string FormatScale(ulong count, LinkedVigesimalScale scale, bool hasRemainder)
    {

View on GitHub (pinned to ffc2b77c0f)

Solutions

  1. Report the locale bug / request higher scales for the locale.
  2. Use a locale with broader numeric coverage.
  3. Clamp inputs to the locale's supported range.
Defensive patterns

Strategy: try-catch

Validate before calling

// Scale/word coverage is internal. No public pre-check; wrap Convert and fall back.

Try / catch

string words;
try
{
    words = value.ToWords(culture);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("lexical word table or scale row"))
{
    words = value.ToWords(CultureInfo.InvariantCulture);
}

Prevention

When it happens

Trigger: value.ToWords(<linked-vigesimal culture>) for a value beyond the Words table length and not covered by any scale row (parts.Count == 0 after the scale loop).

Common situations: Locale profile with scales that don't extend high enough for the input magnitude; a value larger than the largest authored scale plus the Words range.

Related errors


AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13). Data as JSON: /api/errors/fe82e01029595a5a. Report an issue: GitHub.