mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
fix try/catch to catch HttpRequestExceptions
This commit is contained in:
parent
a35b1e9379
commit
115493a0a5
1 changed files with 10 additions and 10 deletions
|
|
@ -33,23 +33,23 @@ public Handler(HttpClient httpClient, ILogger<Handler> logger)
|
|||
|
||||
protected override async Task Handle(Command request, CancellationToken cancellationToken)
|
||||
{
|
||||
using (var response = await _httpClient.GetAsync(request.ListInfo.ViewUrl, cancellationToken))
|
||||
try
|
||||
{
|
||||
if (response.IsSuccessStatusCode)
|
||||
try
|
||||
{
|
||||
using (var response = await _httpClient.GetAsync(request.ListInfo.ViewUrl, cancellationToken))
|
||||
{
|
||||
if (response.IsSuccessStatusCode)
|
||||
using (Stream output =
|
||||
File.OpenWrite(Path.Combine("archives", $"{request.ListInfo.Id}.txt")))
|
||||
using (var input = await response.Content.ReadAsStreamAsync())
|
||||
{
|
||||
input.CopyTo(output);
|
||||
}
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
_logger.LogError(ex,
|
||||
$"Error downloading list {request.ListInfo.Id} from {request.ListInfo.ViewUrl}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
_logger.LogError(ex,
|
||||
$"Error downloading list {request.ListInfo.Id} from {request.ListInfo.ViewUrl}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue