Change TaskCanceledException in WebSearch plugin to operationCanceledException

This commit is contained in:
弘韬 张 2021-02-23 09:53:17 +08:00
parent e2fa9683b9
commit b07b1ddb31
4 changed files with 6 additions and 7 deletions

View file

@ -125,8 +125,7 @@ namespace Flow.Launcher.Plugin.WebSearch
{ {
var suggestions = await source.Suggestions(keyword, token).ConfigureAwait(false); var suggestions = await source.Suggestions(keyword, token).ConfigureAwait(false);
if (token.IsCancellationRequested) token.ThrowIfCancellationRequested();
return null;
var resultsFromSuggestion = suggestions?.Select(o => new Result var resultsFromSuggestion = suggestions?.Select(o => new Result
{ {

View file

@ -25,7 +25,7 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
const string api = "http://suggestion.baidu.com/su?json=1&wd="; const string api = "http://suggestion.baidu.com/su?json=1&wd=";
result = await Http.GetAsync(api + Uri.EscapeUriString(query), token).ConfigureAwait(false); result = await Http.GetAsync(api + Uri.EscapeUriString(query), token).ConfigureAwait(false);
} }
catch (TaskCanceledException) catch (OperationCanceledException)
{ {
return null; return null;
} }

View file

@ -28,7 +28,7 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
json = (await JsonDocument.ParseAsync(resultStream, cancellationToken: token)).RootElement.GetProperty("AS"); json = (await JsonDocument.ParseAsync(resultStream, cancellationToken: token)).RootElement.GetProperty("AS");
} }
catch (TaskCanceledException) catch (OperationCanceledException)
{ {
return new List<string>(); return new List<string>();
} }

View file

@ -24,10 +24,10 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
using var resultStream = await Http.GetStreamAsync(api + Uri.EscapeUriString(query)).ConfigureAwait(false); using var resultStream = await Http.GetStreamAsync(api + Uri.EscapeUriString(query)).ConfigureAwait(false);
json = await JsonDocument.ParseAsync(resultStream); json = await JsonDocument.ParseAsync(resultStream, cancellationToken: token);
} }
catch (TaskCanceledException) catch (OperationCanceledException)
{ {
return new List<string>(); return new List<string>();
} }