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);
if (token.IsCancellationRequested)
return null;
token.ThrowIfCancellationRequested();
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=";
result = await Http.GetAsync(api + Uri.EscapeUriString(query), token).ConfigureAwait(false);
}
catch (TaskCanceledException)
catch (OperationCanceledException)
{
return null;
}

View file

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

View file

@ -23,11 +23,11 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
const string api = "https://www.google.com/complete/search?output=chrome&q=";
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>();
}