Skip to content

Commit 1c0dfc2

Browse files
committed
Merge pull request #14 from PowerShell/Raghu-Changes-1
Actionable messages for ast parser errors
2 parents cf9f239 + 42c4fee commit 1c0dfc2

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Engine/Commands/InvokeScriptAnalyzerCommand.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -274,21 +274,19 @@ private void AnalyzeFile(string filePath)
274274
ErrorCategory.InvalidArgument, filePath));
275275
}
276276

277-
if (errors != null && errors.Length > 0)
277+
if (errors != null && errors.Length > 0)
278278
{
279279
foreach (ParseError error in errors)
280280
{
281-
WriteError(new ErrorRecord(new ParseException(),
282-
String.Format(CultureInfo.CurrentCulture, Strings.ParserErrorFormat, error.Extent.File, error.Message.TrimEnd('.'), error.Extent.StartLineNumber, error.Extent.StartColumnNumber),
283-
ErrorCategory.ParserError, error.ErrorId));
281+
string parseErrorMessage = String.Format(CultureInfo.CurrentCulture, Strings.ParserErrorFormat, error.Extent.File, error.Message.TrimEnd('.'), error.Extent.StartLineNumber, error.Extent.StartColumnNumber);
282+
WriteError(new ErrorRecord(new ParseException(parseErrorMessage), parseErrorMessage, ErrorCategory.ParserError, error.ErrorId));
284283
}
285284
}
286285

287286
if (errors.Length > 10)
288287
{
289-
WriteError(new ErrorRecord(new ParseException(),
290-
String.Format(CultureInfo.CurrentCulture, Strings.ParserErrorMessage, System.IO.Path.GetFileName(filePath)),
291-
ErrorCategory.ParserError, filePath));
288+
string manyParseErrorMessage = String.Format(CultureInfo.CurrentCulture, Strings.ParserErrorMessage, System.IO.Path.GetFileName(filePath));
289+
WriteError(new ErrorRecord(new ParseException(manyParseErrorMessage), manyParseErrorMessage, ErrorCategory.ParserError, filePath));
292290

293291
return;
294292
}

0 commit comments

Comments
 (0)