Skip to content

Commit

Permalink
chore(refactor): make TimeoutError less stringly typed for util name
Browse files Browse the repository at this point in the history
  • Loading branch information
mpeyper committed Dec 23, 2020
1 parent 2bd7222 commit 08d5bb4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/asyncUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export interface WaitOptions {
}

class TimeoutError extends Error {
constructor(utilName: string, timeout: number) {
super(`Timed out in ${utilName} after ${timeout}ms.`)
constructor(util: Function, timeout: number) {
super(`Timed out in ${util.name} after ${timeout}ms.`)
}
}

Expand All @@ -27,7 +27,7 @@ function asyncUtils(addResolver: (callback: () => void) => void) {
let timeoutId: ReturnType<typeof setTimeout>
if (timeout && timeout > 0) {
timeoutId = setTimeout(
() => reject(new TimeoutError('waitForNextUpdate', timeout)),
() => reject(new TimeoutError(waitForNextUpdate, timeout)),
timeout
)
}
Expand Down Expand Up @@ -74,7 +74,7 @@ function asyncUtils(addResolver: (callback: () => void) => void) {
}
} catch (error: unknown) {
if (error instanceof TimeoutError && initialTimeout) {
throw new TimeoutError('waitFor', initialTimeout)
throw new TimeoutError(waitFor, initialTimeout)
}
throw error as Error
}
Expand All @@ -96,7 +96,7 @@ function asyncUtils(addResolver: (callback: () => void) => void) {
})
} catch (error: unknown) {
if (error instanceof TimeoutError && options.timeout) {
throw new TimeoutError('waitForValueToChange', options.timeout)
throw new TimeoutError(waitForValueToChange, options.timeout)
}
throw error as Error
}
Expand Down

0 comments on commit 08d5bb4

Please sign in to comment.