From 76163e256bb9d54a2b7df232a4b173fab2bee661 Mon Sep 17 00:00:00 2001 From: Tadas Date: Fri, 16 Feb 2024 15:06:43 +0000 Subject: [PATCH 1/2] Add exception message for missing rules --- Engine/ScriptAnalyzer.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Engine/ScriptAnalyzer.cs b/Engine/ScriptAnalyzer.cs index 1a885eabe..703e92b76 100644 --- a/Engine/ScriptAnalyzer.cs +++ b/Engine/ScriptAnalyzer.cs @@ -822,13 +822,13 @@ private void Initialize( // Ensure that rules were actually loaded if (rules == null || rules.Any() == false) { + string errorMessage = string.Format( CultureInfo.CurrentCulture, Strings.RulesNotFound); + this.outputWriter.ThrowTerminatingError( new ErrorRecord( - new Exception(), - string.Format( - CultureInfo.CurrentCulture, - Strings.RulesNotFound), - ErrorCategory.ResourceExists, + new Exception(errorMessage), + errorMessage, + ErrorCategory.ResourceUnavailable, this)); } From 61a4f2e3ba608541db6404ad21828334a157b18f Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Fri, 14 Mar 2025 17:13:22 +0000 Subject: [PATCH 2/2] Apply suggestions from code review --- Engine/ScriptAnalyzer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Engine/ScriptAnalyzer.cs b/Engine/ScriptAnalyzer.cs index dedc1a424..f250336b5 100644 --- a/Engine/ScriptAnalyzer.cs +++ b/Engine/ScriptAnalyzer.cs @@ -822,13 +822,13 @@ private void Initialize( // Ensure that rules were actually loaded if (rules == null || rules.Any() == false) { - string errorMessage = string.Format( CultureInfo.CurrentCulture, Strings.RulesNotFound); + string errorMessage = string.Format(CultureInfo.CurrentCulture, Strings.RulesNotFound); this.outputWriter.ThrowTerminatingError( new ErrorRecord( new Exception(errorMessage), errorMessage, - ErrorCategory.ResourceUnavailable, + ErrorCategory.ObjectNotFound, this)); }