{"record":{"id":"9553a318c946c05b","repo":"Humanizr/Humanizer","slug":"unknown-number-to-words-profile","errorCode":null,"errorMessage":"Unknown number-to-words profile.","messagePattern":"Unknown number-to-words profile\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Humanizer.SourceGenerators/Generators/ProfileCatalogs/NumberToWordsProfileCatalogInput.cs","lineNumber":79,"sourceCode":"            builder.AppendLine(\"static partial class NumberToWordsProfileCatalog\");\n            builder.AppendLine(\"{\");\n            builder.AppendLine(\"    public static INumberToWordsConverter Resolve(string kind, CultureInfo culture)\");\n            builder.AppendLine(\"    {\");\n            builder.AppendLine(\"        switch (kind)\");\n            builder.AppendLine(\"        {\");\n\n            foreach (var profile in profiles.OrderBy(static profile => profile.ProfileName, StringComparer.Ordinal))\n            {\n                var expression = CreateProfileExpression(profile, useCultureParameter: RequiresCulture(profile));\n                builder.Append(\"            case \");\n                builder.Append(QuoteLiteral(profile.ProfileName));\n                builder.Append(\": return \");\n                builder.Append(RequiresCulture(profile) ? expression : GetCatalogPropertyName(profile.ProfileName));\n                builder.AppendLine(\";\");\n            }\n\n            builder.AppendLine(\"        }\");\n            builder.AppendLine(\"        throw new ArgumentOutOfRangeException(nameof(kind), kind, \\\"Unknown number-to-words profile.\\\");\");\n            builder.AppendLine(\"    }\");\n            builder.AppendLine();\n\n            foreach (var profile in profiles.OrderBy(static profile => profile.ProfileName, StringComparer.Ordinal))\n            {\n                if (RequiresCulture(profile))\n                {\n                    continue;\n                }\n\n                AppendLazyCachedMember(\n                    builder,\n                    \"    \",\n                    \"static\",\n                    \"INumberToWordsConverter\",\n                    GetCatalogPropertyName(profile.ProfileName),\n                    CreateProfileExpression(profile, useCultureParameter: false));\n                builder.AppendLine();","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/Humanizr/Humanizer/blob/ffc2b77c0f30d2fb176875841424379319d0ae9b/src/Humanizer.SourceGenerators/Generators/ProfileCatalogs/NumberToWordsProfileCatalogInput.cs#L61-L97","documentation":"This message is emitted into generated source code (NumberToWordsProfileCatalog.g.cs) as the default case of a switch on the profile name. At runtime, NumberToWordsProfileCatalog.Resolve(kind, culture) throws ArgumentOutOfRangeException when the kind string is not one of the profile names compiled into the catalog. The catalog only knows profiles that shipped from the locale YAML included in that build.","triggerScenarios":"Calling a number-to-words API (e.g. number.ToWords(...)) with a culture/locale whose name does not match any generated profile. This can happen if the locale's numberToWords feature was not marked UsesGeneratedProfile, or the locale was never included in the build, or the caller passes an ad-hoc string that is not a known culture identifier.","commonSituations":"A consumer upgrades Humanizer and a previously supported locale name changed or was removed. A consumer calls the internal registry with a custom or mistyped culture string. A developer working on locale parity calls Resolve directly with an unfinished profile name during testing.","solutions":["Verify the locale is present under src/Humanizer/Locales and its numberToWords block has a profile name that matches the kind string you are passing.","Ensure the locale's numberToWords feature is registered with UsesGeneratedProfile: true so it appears in the generated catalog switch.","If you are calling the API with a CultureInfo, confirm its Name property resolves to a supported locale (e.g. 'en', 'fr', 'de').","Fall back to a known-supported locale (the default is 'en') when the requested locale is not available."],"exampleFix":"// before — 'xx' is not a shipped number-to-words locale\nvar words = NumberToWords.ToWords(42, \"xx\");\n\n// after — use a supported locale\nvar words = NumberToWords.ToWords(42, \"en\");","handlingStrategy":"validation","validationCode":"// Before calling a number-to-words API with an arbitrary locale,\n// verify the locale is supported.\nvar culture = new CultureInfo(\"fr\");\n// The public API falls back gracefully for unsupported locales via the registry default.\n// If calling NumberToWordsProfileCatalog.Resolve directly (internal), guard the name:\nif (!IsSupportedNumberToWordsLocale(culture.Name))\n    culture = CultureInfo.InvariantCulture; // or 'en'","typeGuard":null,"tryCatchPattern":"try\n{\n    var converter = NumberToWordsProfileCatalog.Resolve(kind, culture);\n}\ncatch (ArgumentOutOfRangeException)\n{\n    // Fall back to the default 'en' profile\n    converter = NumberToWordsProfileCatalog.Resolve(\"en\", culture);\n}","preventionTips":["Use the public NumberToWords API rather than calling the internal catalog Resolve directly.","Prefer CultureInfo objects over raw strings to ensure valid culture names.","Test with the specific locales your application targets."],"tags":["runtime","number-to-words","generated-code","locale","argument-out-of-range"],"backgroundTag":null,"analyzedSha":"ffc2b77c0f30d2fb176875841424379319d0ae9b","analyzedAt":"2026-08-13T21:42:34.584Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}