Skip to content

Commit f08aff3

Browse files
Copilotkilasuit
andcommitted
Use specific exception types in catch blocks for Start-ThreadJob lookup
Co-authored-by: kilasuit <6355225+kilasuit@users.noreply.github.com>
1 parent 986d225 commit f08aff3

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

  • src/System.Management.Automation/engine/runtime/Operations

src/System.Management.Automation/engine/runtime/Operations/MiscOps.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,9 +599,14 @@ internal static void InvokePipelineInBackground(
599599
commandInfo = new CmdletInfo("Start-Job", typeof(StartJobCommand));
600600
}
601601
}
602-
catch
602+
catch (CommandNotFoundException)
603603
{
604-
// Fall back to Start-Job if Start-ThreadJob lookup fails
604+
// Fall back to Start-Job if Start-ThreadJob is not found
605+
commandInfo = new CmdletInfo("Start-Job", typeof(StartJobCommand));
606+
}
607+
catch (InvalidOperationException)
608+
{
609+
// Fall back to Start-Job if cmdlet lookup fails
605610
commandInfo = new CmdletInfo("Start-Job", typeof(StartJobCommand));
606611
}
607612
}

0 commit comments

Comments
 (0)