Skip to content

Commit a68c69b

Browse files
authored
Merge pull request #3604 from Flow-Launcher/resolve_task_exception
Use try-catch to resolve SendAsync issue
2 parents b69a8ee + 03c0ea8 commit a68c69b

File tree

1 file changed

+8
-2
lines changed
  • Flow.Launcher.Infrastructure/Http

1 file changed

+8
-2
lines changed

Flow.Launcher.Infrastructure/Http/Http.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ public static async Task<string> GetAsync([NotNull] Uri url, CancellationToken t
182182
public static Task<Stream> GetStreamAsync([NotNull] string url,
183183
CancellationToken token = default) => GetStreamAsync(new Uri(url), token);
184184

185-
186185
/// <summary>
187186
/// Send a GET request to the specified Uri with an HTTP completion option and a cancellation token as an asynchronous operation.
188187
/// </summary>
@@ -212,7 +211,14 @@ public static async Task<HttpResponseMessage> GetResponseAsync([NotNull] Uri url
212211
/// </summary>
213212
public static async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption = HttpCompletionOption.ResponseContentRead, CancellationToken token = default)
214213
{
215-
return await client.SendAsync(request, completionOption, token);
214+
try
215+
{
216+
return await client.SendAsync(request, completionOption, token);
217+
}
218+
catch (System.Exception)
219+
{
220+
return new HttpResponseMessage(HttpStatusCode.InternalServerError);
221+
}
216222
}
217223
}
218224
}

0 commit comments

Comments
 (0)