limit scope of try block

This commit is contained in:
Collin M. Barrett 2019-07-02 09:17:38 -05:00
parent dddb9f3d28
commit 0bf807f01e

View file

@ -82,26 +82,26 @@ private ActionBlock<ListInfo> BuildDownloader(CancellationToken cancellationToke
async l =>
{
var errorMessage = $"Error downloading list {l.Id} from {l.ViewUrl}.";
try
var extension = l.ViewUrl.GetExtension();
if (CommandsByExtension.ContainsKey(extension))
{
var extension = l.ViewUrl.GetExtension();
if (CommandsByExtension.ContainsKey(extension))
var command = CommandsByExtension[extension].Invoke(l);
try
{
var command = CommandsByExtension[extension].Invoke(l);
await _mediator.Send(command, cancellationToken);
}
else
catch (HttpRequestException ex)
{
_logger.LogError($"The file extension of list {l.Id} from {l.ViewUrl} is not supported.");
_logger.LogError(ex, errorMessage);
}
catch (TaskCanceledException ex)
{
_logger.LogError(ex, errorMessage);
}
}
catch (HttpRequestException ex)
else
{
_logger.LogError(ex, errorMessage);
}
catch (TaskCanceledException ex)
{
_logger.LogError(ex, errorMessage);
_logger.LogError($"The file extension of list {l.Id} from {l.ViewUrl} is not supported.");
}
},
new ExecutionDataflowBlockOptions {MaxDegreeOfParallelism = MaxDegreeOfParallelism}