Skip to content

Commit f27da68

Browse files
committed
Catch RuntimeException when getting signatures with bad attribute
This change catches a RuntimeException that may occur when the user types out the name of a command or script which uses an invalid parameter binding attribute. This exception will be logged and the signatures just won't be displayed for that command. Resolves #462.
1 parent 447b447 commit f27da68

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/PowerShellEditorServices/Language/LanguageService.cs

+9
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,15 @@ await CommandHelpers.GetCommandInfo(
481481
IEnumerable<CommandParameterSetInfo> commandParamSets = commandInfo.ParameterSets;
482482
return new ParameterSetSignatures(commandParamSets, foundSymbol);
483483
}
484+
catch (RuntimeException e)
485+
{
486+
// A RuntimeException will be thrown when an invalid attribute is
487+
// on a parameter binding block and then that command/script has
488+
// its signatures resolved by typing it into a script.
489+
Logger.WriteException("RuntimeException encountered while accessing command parameter sets", e);
490+
491+
return null;
492+
}
484493
catch (InvalidOperationException)
485494
{
486495
// For some commands there are no paramsets (like applications). Until

0 commit comments

Comments
 (0)