Skip to content

Commit 890f114

Browse files
authored
Merge pull request #364 from Flow-Launcher/FixUpdateCancelledException
change taskcanceledexception to operationcanceledexception
2 parents 0683640 + 3a45c99 commit 890f114

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

Flow.Launcher.Core/Updater.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public async Task UpdateApp(IPublicAPI api, bool silentUpdate = true)
8787
UpdateManager.RestartApp(Constant.ApplicationFileName);
8888
}
8989
}
90-
catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException || e is TaskCanceledException)
90+
catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException || e.InnerException is TimeoutException)
9191
{
9292
Log.Exception($"|Updater.UpdateApp|Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e);
9393
api.ShowMsg(api.GetTranslation("update_flowlauncher_fail"),

Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ private async Task<IEnumerable<Result>> SuggestionsAsync(string keyword, string
125125
{
126126
var suggestions = await source.Suggestions(keyword, token).ConfigureAwait(false);
127127

128-
if (token.IsCancellationRequested)
129-
return null;
128+
token.ThrowIfCancellationRequested();
130129

131130
var resultsFromSuggestion = suggestions?.Select(o => new Result
132131
{

Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Baidu.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@ public override async Task<List<string>> Suggestions(string query, CancellationT
2525
const string api = "http://suggestion.baidu.com/su?json=1&wd=";
2626
result = await Http.GetAsync(api + Uri.EscapeUriString(query), token).ConfigureAwait(false);
2727
}
28-
catch (TaskCanceledException)
28+
catch (Exception e) when (e is HttpRequestException || e.InnerException is TimeoutException)
2929
{
30+
Log.Exception("|Baidu.Suggestions|Can't get suggestion from baidu", e);
3031
return null;
3132
}
32-
catch (HttpRequestException e)
33+
catch (OperationCanceledException)
3334
{
34-
Log.Exception("|Baidu.Suggestions|Can't get suggestion from baidu", e);
3535
return null;
3636
}
3737

38+
3839
if (string.IsNullOrEmpty(result)) return new List<string>();
3940
Match match = _reg.Match(result);
4041
if (match.Success)
@@ -44,7 +45,7 @@ public override async Task<List<string>> Suggestions(string query, CancellationT
4445
{
4546
json = JsonDocument.Parse(match.Groups[1].Value);
4647
}
47-
catch(JsonException e)
48+
catch (JsonException e)
4849
{
4950
Log.Exception("|Baidu.Suggestions|can't parse suggestions", e);
5051
return new List<string>();

Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Bing.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ public override async Task<List<string>> Suggestions(string query, CancellationT
2828
json = (await JsonDocument.ParseAsync(resultStream, cancellationToken: token)).RootElement.GetProperty("AS");
2929

3030
}
31-
catch (TaskCanceledException)
31+
catch (Exception e) when (e is HttpRequestException || e.InnerException is TimeoutException)
3232
{
33-
return new List<string>();
33+
Log.Exception("|Baidu.Suggestions|Can't get suggestion from baidu", e);
34+
return null;
3435
}
35-
catch (HttpRequestException e)
36+
catch (OperationCanceledException)
3637
{
37-
Log.Exception("|Bing.Suggestions|Can't get suggestion from Bing", e);
3838
return new List<string>();
3939
}
4040
catch (JsonException e)

Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Google.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ public override async Task<List<string>> Suggestions(string query, CancellationT
2323
const string api = "https://www.google.com/complete/search?output=chrome&q=";
2424

2525
using var resultStream = await Http.GetStreamAsync(api + Uri.EscapeUriString(query)).ConfigureAwait(false);
26-
27-
json = await JsonDocument.ParseAsync(resultStream);
26+
27+
json = await JsonDocument.ParseAsync(resultStream, cancellationToken: token);
2828

2929
}
30-
catch (TaskCanceledException)
30+
catch (Exception e) when (e is HttpRequestException || e.InnerException is TimeoutException)
3131
{
32-
return new List<string>();
32+
Log.Exception("|Baidu.Suggestions|Can't get suggestion from baidu", e);
33+
return null;
3334
}
34-
catch (HttpRequestException e)
35+
catch (OperationCanceledException)
3536
{
36-
Log.Exception("|Google.Suggestions|Can't get suggestion from google", e);
3737
return new List<string>();
3838
}
3939
catch (JsonException e)

Plugins/Flow.Launcher.Plugin.WebSearch/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"Name": "Web Searches",
2626
"Description": "Provide the web search ability",
2727
"Author": "qianlifeng",
28-
"Version": "1.3.2",
28+
"Version": "1.3.3",
2929
"Language": "csharp",
3030
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
3131
"ExecuteFileName": "Flow.Launcher.Plugin.WebSearch.dll",

0 commit comments

Comments
 (0)