From f61fa815b8e147642e0df47452a555932ff9fd0b Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 1 Jul 2022 19:11:24 +0000 Subject: [PATCH] --- AyaNovaQBI/util.cs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/AyaNovaQBI/util.cs b/AyaNovaQBI/util.cs index 0f0deaf..c29e412 100644 --- a/AyaNovaQBI/util.cs +++ b/AyaNovaQBI/util.cs @@ -364,7 +364,7 @@ namespace AyaNovaQBI } - + public async static Task PutAsync(string route, dynamic d) { Exception FirstException = null; @@ -387,6 +387,28 @@ namespace AyaNovaQBI throw new Exception($"API call failed after {MAX_TRIES.ToString()} attempts", FirstException); } + public async static Task PutAsync(string route, string s=null) + { + Exception FirstException = null; + + for (int x = 0; x < MAX_TRIES; x++) + { + try + { + return await TryPutAsync(route, s); + } + catch (Exception ex) + { + if (FirstException == null) + FirstException = ex; + } + await Task.Delay(API_RETRY_DELAY); + } + + //no luck re-throw the exception + throw new Exception($"API call failed after {MAX_TRIES.ToString()} attempts", FirstException); + } + public async static Task PutAsync(string route) { Exception FirstException = null;