From dfc591c218ae2647e23577ebd77a380b3193e5f0 Mon Sep 17 00:00:00 2001 From: Ilya Date: Wed, 28 Oct 2020 01:54:52 +0500 Subject: [PATCH] Fix NRE in Test-Json (#12942) --- .../commands/utility/TestJsonCommand.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/TestJsonCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/TestJsonCommand.cs index 668c50728..3b9655cad 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/TestJsonCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/TestJsonCommand.cs @@ -59,7 +59,7 @@ namespace Microsoft.PowerShell.Commands /// Return value is unreachable since we always rethrow. private static bool UnwrapException(Exception e) { - if (e is TargetInvocationException) + if (e.InnerException != null && e is TargetInvocationException) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); }