From 2e3ebd476e92aee1011b04e4d61fb14824204a02 Mon Sep 17 00:00:00 2001 From: Christopher Scott Date: Wed, 8 Sep 2021 11:55:10 -0500 Subject: [PATCH] Fix error message logic (#1990) * Fix error message logic --- .../Azure.Sdk.Tools.SnippetGenerator/Program.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tools/snippet-generator/Azure.Sdk.Tools.SnippetGenerator/Program.cs b/tools/snippet-generator/Azure.Sdk.Tools.SnippetGenerator/Program.cs index c6985224324..45f0185a702 100644 --- a/tools/snippet-generator/Azure.Sdk.Tools.SnippetGenerator/Program.cs +++ b/tools/snippet-generator/Azure.Sdk.Tools.SnippetGenerator/Program.cs @@ -41,19 +41,17 @@ public async Task OnExecuteAsync() unUsedSnippets = (await new DirectoryProcessor(BasePath).ProcessAsync()).ToList(); } Console.WriteLine(); - string message = $"Not all snippets were used.\n{string.Join(Environment.NewLine, unUsedSnippets)}"; - unUsedSnippets.Sort(); - if (StrictMode) + if (unUsedSnippets.Any()) { - if (unUsedSnippets.Any()) + string message = $"Not all snippets were used.\n{string.Join(Environment.NewLine, unUsedSnippets)}"; + unUsedSnippets.Sort(); + if (StrictMode) { throw new InvalidOperationException(message); } - } - else - { WriteError(message); } + sw.Stop(); Console.WriteLine($"SnippetGenerator completed in {sw.Elapsed}"); }