Skip to content

Commit a99bd2e

Browse files
committed
enhance: only dispatch error message if it contains valid data
1 parent 2692343 commit a99bd2e

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/Commands/Command.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,8 @@ public bool Exec()
104104
catch (Exception e)
105105
{
106106
if (RaiseError)
107-
{
108-
Dispatcher.UIThread.Invoke(() =>
109-
{
110-
App.RaiseException(Context, e.Message);
111-
});
112-
}
107+
Dispatcher.UIThread.Post(() => App.RaiseException(Context, e.Message));
108+
113109
return false;
114110
}
115111

@@ -120,15 +116,15 @@ public bool Exec()
120116
int exitCode = proc.ExitCode;
121117
proc.Close();
122118

123-
if (!isCancelled && exitCode != 0 && errs.Count > 0)
119+
if (!isCancelled && exitCode != 0)
124120
{
125121
if (RaiseError)
126122
{
127-
Dispatcher.UIThread.Invoke(() =>
128-
{
129-
App.RaiseException(Context, string.Join("\n", errs));
130-
});
123+
var errMsg = string.Join("\n", errs);
124+
if (!string.IsNullOrWhiteSpace(errMsg))
125+
Dispatcher.UIThread.Post(() => App.RaiseException(Context, errMsg));
131126
}
127+
132128
return false;
133129
}
134130

0 commit comments

Comments
 (0)