Skip to content

Commit

Permalink
Add try/catch around formatter registration to handle OS's that don't…
Browse files Browse the repository at this point in the history
… support a particular culture.
  • Loading branch information
clairernovotny committed May 5, 2021
1 parent b8c06d7 commit 92f76a4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Humanizer/Configuration/FormatterRegistry.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Humanizer.Localisation.Formatters;
using System.Globalization;

using Humanizer.Localisation.Formatters;

namespace Humanizer.Configuration
{
Expand Down Expand Up @@ -56,7 +58,14 @@ public FormatterRegistry() : base(new DefaultFormatter("en-US"))

private void RegisterDefaultFormatter(string localeCode)
{
Register(localeCode, new DefaultFormatter(localeCode));
try
{
Register(localeCode, new DefaultFormatter(localeCode));
}
catch (CultureNotFoundException)
{
// Some OS's may not support the particular culture. Not much we can do for those.
}
}

private void RegisterCzechSlovakPolishFormatter(string localeCode)
Expand Down

0 comments on commit 92f76a4

Please sign in to comment.