- fix: profiles token refresh now
This commit is contained in:
19
Nebula.Shared/Utils/ExceptionHelper.cs
Normal file
19
Nebula.Shared/Utils/ExceptionHelper.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace Nebula.Shared.Utils;
|
||||
|
||||
public static class ExceptionHelper
|
||||
{
|
||||
public static Task<T> TryRun<T>(Func<Task<T>> func, int attempts = 3, Action<int, Exception>? attemptsCallback = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
return func.Invoke();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (attempts <= 0) throw new("Attempts was expired! ", e);
|
||||
attempts--;
|
||||
attemptsCallback?.Invoke(attempts, e);
|
||||
return TryRun(func, attempts);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user