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);
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);
});
}
}
}
}