From 680cdca28da1905b9c4acca79b6f7bb39e016434 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 5 Nov 2024 12:15:20 +0800 Subject: [PATCH] feature: handle custom action error output Signed-off-by: leo --- src/Commands/ExecuteCustomAction.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Commands/ExecuteCustomAction.cs b/src/Commands/ExecuteCustomAction.cs index 253c6b43..10ecb450 100644 --- a/src/Commands/ExecuteCustomAction.cs +++ b/src/Commands/ExecuteCustomAction.cs @@ -30,6 +30,8 @@ namespace SourceGit.Commands start.Environment.Add("PATH", Native.OS.CustomPathEnv); var proc = new Process() { StartInfo = start }; + var builder = new StringBuilder(); + proc.OutputDataReceived += (_, e) => { if (e.Data != null) @@ -39,7 +41,10 @@ namespace SourceGit.Commands proc.ErrorDataReceived += (_, e) => { if (e.Data != null) + { outputHandler?.Invoke(e.Data); + builder.Append(e.Data); + } }; try @@ -57,7 +62,17 @@ namespace SourceGit.Commands }); } + var exitCode = proc.ExitCode; proc.Close(); + + if (exitCode != 0) + { + var errMsg = builder.ToString(); + Dispatcher.UIThread.Invoke(() => + { + App.RaiseException(repo, errMsg); + }); + } } } }