Throw critical errors on nexus API quota issues

This commit is contained in:
Timothy Baldridge 2020-11-14 07:21:13 -07:00
parent 01872fb62b
commit e1725bb808
3 changed files with 20 additions and 1 deletions

View File

@ -200,6 +200,11 @@ namespace Wabbajack.Lib.Downloaders
var client = await NexusApiClient.Get();
url = await client.GetNexusDownloadLink(this);
}
catch (NexusAPIQuotaExceeded ex)
{
Utils.Log(ex.ExtendedDescription);
throw;
}
catch (Exception ex)
{
return false;
@ -248,6 +253,8 @@ namespace Wabbajack.Lib.Downloaders
public override async Task<(Archive? Archive, TempFile NewFile)> FindUpgrade(Archive a, Func<Archive, Task<AbsolutePath>> downloadResolver)
{
var client = await NexusApiClient.Get();
if (client.RemainingAPICalls <= 0)
throw new NexusAPIQuotaExceeded();
var mod = await client.GetModInfo(Game, ModID);
if (!mod.available)

View File

@ -311,7 +311,7 @@ namespace Wabbajack.Lib.NexusApi
{
if (HourlyRemaining <= 0 && DailyRemaining <= 0)
{
throw new Exception($"You have run out of Nexus API requests, please try again after midnight GMT when the API limits reset");
throw new NexusAPIQuotaExceeded();
}
var url =

View File

@ -0,0 +1,12 @@
using Wabbajack.Common.StatusFeed;
namespace Wabbajack.Lib
{
public class NexusAPIQuotaExceeded : AErrorMessage
{
public override string ShortDescription => $"You have exceeded your Nexus API limit for the day";
public override string ExtendedDescription =>
"You have exceeded your Nexus API limit for the day, please try again after midnight GMT";
}
}