Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exception message for missing rules #1968

Merged
merged 5 commits into from
Mar 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Engine/ScriptAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Copy link
Collaborator

@bergmeister bergmeister Feb 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where this error is thrown, are we sure the only reason could be missing rules @Tadas ?
Kicked off CI for now to see what tests say

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bergmeister I know we didn't get an answer to this; thoughts on merging for v1.3?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, on closer inspection of the diff, only 2 things are changing and they aren't of concern:

  • errorMessage is passed into Exception instead of nothing, which is an improvement
  • ErrorCategory is changed from ResourceExists to ResourceUnavailable, which I guess is a bit better but ObjectNotFound is maybe even better so will change it to that. This is the same category that gci notExists returns

errorMessage,
ErrorCategory.ObjectNotFound,
this));
}

Expand Down