remove unnecessary catching OperationCanceledException

This commit is contained in:
Jeremy Wu 2021-03-18 06:50:55 +11:00
parent f4971e2e96
commit 9479923531
5 changed files with 12 additions and 43 deletions

View file

@ -63,10 +63,6 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
}
}
}
catch (OperationCanceledException)
{
return new List<Result>(); // The source code indicates that without adding members, it won't allocate an array
}
catch (InvalidOperationException e)
{
// Internal error from ExecuteReader(): Connection closed.

View file

@ -50,35 +50,21 @@ namespace Flow.Launcher.Plugin.Program
win32 = _win32s;
uwps = _uwps;
try
var result = await Task.Run(delegate
{
var result = await Task.Run(delegate
{
try
{
return win32.Cast<IProgram>()
.Concat(uwps)
.AsParallel()
.WithCancellation(token)
.Where(p => p.Enabled)
.Select(p => p.Result(query.Search, _context.API))
.Where(r => r?.Score > 0)
.ToList();
}
catch (OperationCanceledException)
{
return null;
}
}, token).ConfigureAwait(false);
return win32.Cast<IProgram>()
.Concat(uwps)
.AsParallel()
.WithCancellation(token)
.Where(p => p.Enabled)
.Select(p => p.Result(query.Search, _context.API))
.Where(r => r?.Score > 0)
.ToList();
}, token).ConfigureAwait(false);
token.ThrowIfCancellationRequested();
token.ThrowIfCancellationRequested();
return result;
}
catch (OperationCanceledException)
{
return null;
}
return result;
}
public async Task InitAsync(PluginInitContext context)

View file

@ -30,11 +30,6 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
Log.Exception("|Baidu.Suggestions|Can't get suggestion from baidu", e);
return null;
}
catch (OperationCanceledException)
{
return null;
}
if (string.IsNullOrEmpty(result)) return new List<string>();
Match match = _reg.Match(result);

View file

@ -45,10 +45,6 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
Log.Exception("|Baidu.Suggestions|Can't get suggestion from baidu", e);
return null;
}
catch (OperationCanceledException)
{
return new List<string>();
}
catch (JsonException e)
{
Log.Exception("|Bing.Suggestions|can't parse suggestions", e);

View file

@ -37,10 +37,6 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
Log.Exception("|Baidu.Suggestions|Can't get suggestion from baidu", e);
return null;
}
catch (OperationCanceledException)
{
return new List<string>();
}
catch (JsonException e)
{
Log.Exception("|Google.Suggestions|can't parse suggestions", e);