feature: handle custom action error output

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2024-11-05 12:15:20 +08:00
parent 9d2c2df6b3
commit 680cdca28d
No known key found for this signature in database

View file

@ -30,6 +30,8 @@ namespace SourceGit.Commands
start.Environment.Add("PATH", Native.OS.CustomPathEnv); start.Environment.Add("PATH", Native.OS.CustomPathEnv);
var proc = new Process() { StartInfo = start }; var proc = new Process() { StartInfo = start };
var builder = new StringBuilder();
proc.OutputDataReceived += (_, e) => proc.OutputDataReceived += (_, e) =>
{ {
if (e.Data != null) if (e.Data != null)
@ -39,7 +41,10 @@ namespace SourceGit.Commands
proc.ErrorDataReceived += (_, e) => proc.ErrorDataReceived += (_, e) =>
{ {
if (e.Data != null) if (e.Data != null)
{
outputHandler?.Invoke(e.Data); outputHandler?.Invoke(e.Data);
builder.Append(e.Data);
}
}; };
try try
@ -57,7 +62,17 @@ namespace SourceGit.Commands
}); });
} }
var exitCode = proc.ExitCode;
proc.Close(); proc.Close();
if (exitCode != 0)
{
var errMsg = builder.ToString();
Dispatcher.UIThread.Invoke(() =>
{
App.RaiseException(repo, errMsg);
});
}
} }
} }
} }