diff --git a/src/CommandLine/ParserSettings.cs b/src/CommandLine/ParserSettings.cs index 07c10c4c..bc523deb 100644 --- a/src/CommandLine/ParserSettings.cs +++ b/src/CommandLine/ParserSettings.cs @@ -41,13 +41,12 @@ public ParserSettings() private int GetWindowWidth() { - -#if !NET40 - if (Console.IsOutputRedirected) return DefaultMaximumLength; -#endif var width = 1; try { +#if !NET40 + if (Console.IsOutputRedirected) return DefaultMaximumLength; +#endif width = Console.WindowWidth; if (width < 1) { diff --git a/src/CommandLine/Text/HelpText.cs b/src/CommandLine/Text/HelpText.cs index f5e9a7b9..9e96dbc6 100644 --- a/src/CommandLine/Text/HelpText.cs +++ b/src/CommandLine/Text/HelpText.cs @@ -191,7 +191,7 @@ public HelpText(SentenceBuilder sentenceBuilder, string heading, string copyrigh maximumDisplayWidth = DefaultMaximumLength; } } - catch (IOException) + catch (Exception e) when ( e is IOException || e is PlatformNotSupportedException) { maximumDisplayWidth = DefaultMaximumLength; }