Merge pull request #1920 from wabbajack-tools/try-catch-validation

Add some try/catch around list validation
This commit is contained in:
Timothy Baldridge 2022-04-22 06:30:38 -06:00 committed by GitHub
commit 5558096c55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 7 deletions

View File

@ -137,8 +137,9 @@ public class ValidateLists : IVerb
modListData =
await StandardInstaller.Load(_dtos, _dispatcher, modList, token);
}
catch (JsonException ex)
catch (Exception ex)
{
_logger.LogError(ex, "Forcing down {Modlist} due to error while loading: ", modList.NamespacedName);
validatedList.Status = ListStatus.ForcedDown;
return validatedList;
}

View File

@ -176,13 +176,16 @@ public class HttpDownloader : ADownloader<DTOs.DownloadStates.Http>, IUrlDownloa
public override async Task<byte[]> LoadChunk(long offset, int size)
{
var msg = HttpDownloader.MakeMessage(_state);
msg.Headers.Range = new RangeHeaderValue(offset, offset + size);
using var response = await _downloader._client.SendAsync(msg);
if (!response.IsSuccessStatusCode)
throw new HttpException(response);
return await CircuitBreaker.WithAutoRetryAllAsync(_downloader._logger, async () =>
{
var msg = HttpDownloader.MakeMessage(_state);
msg.Headers.Range = new RangeHeaderValue(offset, offset + size);
using var response = await _downloader._client.SendAsync(msg);
if (!response.IsSuccessStatusCode)
throw new HttpException(response);
return await response.Content.ReadAsByteArrayAsync();
return await response.Content.ReadAsByteArrayAsync();
});
}
}
}