From 443c098fa3cb2dc46277d9f568abf98d33ff18fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Mon, 8 Jan 2024 14:34:13 +0100 Subject: [PATCH] Turn Win32Exception from ChildProcess.Start() into ChildProcessException. --- src/core/Processes/ChildProcess.cs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/core/Processes/ChildProcess.cs b/src/core/Processes/ChildProcess.cs index fff6f2a..c2a7285 100644 --- a/src/core/Processes/ChildProcess.cs +++ b/src/core/Processes/ChildProcess.cs @@ -89,19 +89,26 @@ internal ChildProcess(ChildProcessBuilder builder) _exited.SetResult(); }; - // If the child process might use the terminal, start it under the raw mode lock since we only allow starting - // non-redirected processes in cooked mode and we need to verify our current mode. - if (terminal) + try { - Terminal.System.StartProcess(() => + // If the child process might use the terminal, start it under the raw mode lock since we only allow + // starting non-redirected processes in cooked mode and we need to verify our current mode. + if (terminal) { - _ = _process.Start(); + Terminal.System.StartProcess(() => + { + _ = _process.Start(); - return this; - }); + return this; + }); + } + else + _ = _process.Start(); + } + catch (Win32Exception ex) + { + throw new ChildProcessException("Failed to start child process.", ex); } - else - _ = _process.Start(); Id = _process.Id;