mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #3604 from Flow-Launcher/resolve_task_exception
Use try-catch to resolve SendAsync issue
This commit is contained in:
commit
a68c69bb06
1 changed files with 8 additions and 2 deletions
|
|
@ -182,7 +182,6 @@ namespace Flow.Launcher.Infrastructure.Http
|
||||||
public static Task<Stream> GetStreamAsync([NotNull] string url,
|
public static Task<Stream> GetStreamAsync([NotNull] string url,
|
||||||
CancellationToken token = default) => GetStreamAsync(new Uri(url), token);
|
CancellationToken token = default) => GetStreamAsync(new Uri(url), token);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Send a GET request to the specified Uri with an HTTP completion option and a cancellation token as an asynchronous operation.
|
/// Send a GET request to the specified Uri with an HTTP completion option and a cancellation token as an asynchronous operation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -212,7 +211,14 @@ namespace Flow.Launcher.Infrastructure.Http
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption = HttpCompletionOption.ResponseContentRead, CancellationToken token = default)
|
public static async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption = HttpCompletionOption.ResponseContentRead, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
return await client.SendAsync(request, completionOption, token);
|
try
|
||||||
|
{
|
||||||
|
return await client.SendAsync(request, completionOption, token);
|
||||||
|
}
|
||||||
|
catch (System.Exception)
|
||||||
|
{
|
||||||
|
return new HttpResponseMessage(HttpStatusCode.InternalServerError);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue