use throw instead of return empty string

This commit is contained in:
弘韬 张 2021-02-09 14:03:22 +08:00
parent b15319ea4d
commit f93dcaef73

View file

@ -185,14 +185,18 @@ namespace Flow.Launcher.Core.Plugin
} }
using var standardOutput = process.StandardOutput; using var standardOutput = process.StandardOutput;
token.ThrowIfCancellationRequested();
var result = await standardOutput.ReadToEndAsync(); var result = await standardOutput.ReadToEndAsync();
if (token.IsCancellationRequested) token.ThrowIfCancellationRequested();
return string.Empty;
if (string.IsNullOrEmpty(result)) if (string.IsNullOrEmpty(result))
{ {
using var standardError = process.StandardError; using var standardError = process.StandardError;
var error = await standardError.ReadToEndAsync(); var error = await standardError.ReadToEndAsync();
token.ThrowIfCancellationRequested();
if (!string.IsNullOrEmpty(error)) if (!string.IsNullOrEmpty(error))
{ {
Log.Error($"|JsonRPCPlugin.ExecuteAsync|{error}"); Log.Error($"|JsonRPCPlugin.ExecuteAsync|{error}");