mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-01-08 00:13:08 +00:00
handles exception in GetPurchaseStatus
This commit is contained in:
parent
f58a42a1ca
commit
855b627823
@ -152,17 +152,25 @@ namespace CodexClient
|
|||||||
return mapper.Map(space);
|
return mapper.Map(space);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StoragePurchase GetPurchaseStatus(string purchaseId)
|
public StoragePurchase? GetPurchaseStatus(string purchaseId)
|
||||||
{
|
{
|
||||||
return CrashCheck(() =>
|
return CrashCheck(() =>
|
||||||
{
|
{
|
||||||
var endpoint = GetEndpoint();
|
var endpoint = GetEndpoint();
|
||||||
|
try
|
||||||
|
{
|
||||||
return Time.Retry(() =>
|
return Time.Retry(() =>
|
||||||
{
|
{
|
||||||
var str = endpoint.HttpGetString($"storage/purchases/{purchaseId}");
|
var str = endpoint.HttpGetString($"storage/purchases/{purchaseId}");
|
||||||
if (string.IsNullOrEmpty(str)) throw new Exception("Empty response.");
|
if (string.IsNullOrEmpty(str)) throw new Exception("Empty response.");
|
||||||
return JsonConvert.DeserializeObject<StoragePurchase>(str)!;
|
return JsonConvert.DeserializeObject<StoragePurchase>(str)!;
|
||||||
}, nameof(GetPurchaseStatus));
|
}, 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.
|
// TODO: current getpurchase api does not line up with its openapi spec.
|
||||||
|
|||||||
@ -30,7 +30,7 @@ namespace CodexClient
|
|||||||
IMarketplaceAccess Marketplace { get; }
|
IMarketplaceAccess Marketplace { get; }
|
||||||
ITransferSpeeds TransferSpeeds { get; }
|
ITransferSpeeds TransferSpeeds { get; }
|
||||||
EthAccount EthAccount { get; }
|
EthAccount EthAccount { get; }
|
||||||
StoragePurchase GetPurchaseStatus(string purchaseId);
|
StoragePurchase? GetPurchaseStatus(string purchaseId);
|
||||||
|
|
||||||
Address GetDiscoveryEndpoint();
|
Address GetDiscoveryEndpoint();
|
||||||
Address GetApiEndpoint();
|
Address GetApiEndpoint();
|
||||||
@ -86,7 +86,7 @@ namespace CodexClient
|
|||||||
public DebugInfoVersion Version { get; private set; }
|
public DebugInfoVersion Version { get; private set; }
|
||||||
public ITransferSpeeds TransferSpeeds { get => transferSpeeds; }
|
public ITransferSpeeds TransferSpeeds { get => transferSpeeds; }
|
||||||
|
|
||||||
public StoragePurchase GetPurchaseStatus(string purchaseId)
|
public StoragePurchase? GetPurchaseStatus(string purchaseId)
|
||||||
{
|
{
|
||||||
return codexAccess.GetPurchaseStatus(purchaseId);
|
return codexAccess.GetPurchaseStatus(purchaseId);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user