From 6870232c49769a3c6b27afd905daeed57ea9d395 Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Fri, 15 Sep 2023 10:21:21 +0900 Subject: [PATCH] fix: export RetryOptions interface --- packages/shared-lib/src/error.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/shared-lib/src/error.ts b/packages/shared-lib/src/error.ts index 1d54e852..afe5e97f 100644 --- a/packages/shared-lib/src/error.ts +++ b/packages/shared-lib/src/error.ts @@ -52,6 +52,14 @@ export async function ignoreEnoentAsync(fn: () => Promise): Promise Promise) | undefined; + handleError: ((error: unknown) => Promise) | undefined; + retryCount: number; + retryLogger: ((message: string) => void) | undefined; + sleepMilliseconds: number; +} + /** * Retry the given function. * @param func The function to retry. @@ -64,12 +72,12 @@ export async function ignoreEnoentAsync(fn: () => Promise): Promise( func: (failedCount: number) => Promise, { - beforeRetry = undefined as ((error: unknown) => Promise) | undefined, - handleError = undefined as ((error: unknown) => Promise) | undefined, + beforeRetry = undefined, + handleError = undefined, retryCount = 3, - retryLogger = undefined as ((message: string) => void) | undefined, + retryLogger = undefined, sleepMilliseconds = 0, - } + }: RetryOptions ): Promise { let failedCount = 0; for (;;) {