diff --git a/ProjectPlugins/CodexClient/CodexAccess.cs b/ProjectPlugins/CodexClient/CodexAccess.cs index 27baae14..7c95ce25 100644 --- a/ProjectPlugins/CodexClient/CodexAccess.cs +++ b/ProjectPlugins/CodexClient/CodexAccess.cs @@ -152,17 +152,25 @@ namespace CodexClient return mapper.Map(space); } - public StoragePurchase GetPurchaseStatus(string purchaseId) + public StoragePurchase? GetPurchaseStatus(string purchaseId) { return CrashCheck(() => { var endpoint = GetEndpoint(); - return Time.Retry(() => + try { - var str = endpoint.HttpGetString($"storage/purchases/{purchaseId}"); - if (string.IsNullOrEmpty(str)) throw new Exception("Empty response."); - return JsonConvert.DeserializeObject(str)!; - }, nameof(GetPurchaseStatus)); + return Time.Retry(() => + { + var str = endpoint.HttpGetString($"storage/purchases/{purchaseId}"); + if (string.IsNullOrEmpty(str)) throw new Exception("Empty response."); + return JsonConvert.DeserializeObject(str)!; + }, nameof(GetPurchaseStatus)); + } + catch (Exception exc) + { + log.Error($"Failed to fetch purchase information for id: '{purchaseId}'. Exception: {exc.Message}"); + return null; + } }); // TODO: current getpurchase api does not line up with its openapi spec. diff --git a/ProjectPlugins/CodexClient/CodexNode.cs b/ProjectPlugins/CodexClient/CodexNode.cs index df18079c..330860df 100644 --- a/ProjectPlugins/CodexClient/CodexNode.cs +++ b/ProjectPlugins/CodexClient/CodexNode.cs @@ -30,7 +30,7 @@ namespace CodexClient IMarketplaceAccess Marketplace { get; } ITransferSpeeds TransferSpeeds { get; } EthAccount EthAccount { get; } - StoragePurchase GetPurchaseStatus(string purchaseId); + StoragePurchase? GetPurchaseStatus(string purchaseId); Address GetDiscoveryEndpoint(); Address GetApiEndpoint(); @@ -86,7 +86,7 @@ namespace CodexClient public DebugInfoVersion Version { get; private set; } public ITransferSpeeds TransferSpeeds { get => transferSpeeds; } - public StoragePurchase GetPurchaseStatus(string purchaseId) + public StoragePurchase? GetPurchaseStatus(string purchaseId) { return codexAccess.GetPurchaseStatus(purchaseId); }