Skip to content

Commit aa832db

Browse files
authored
fix: Add TimeoutError. (#428)
1 parent 00ad5fa commit aa832db

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

packages/shared/common/src/errors.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ export class LDClientError extends Error {
4343
}
4444
}
4545

46+
export class LDTimeoutError extends Error {
47+
constructor(message: string) {
48+
super(message);
49+
this.name = 'LaunchDarklyTimeoutError';
50+
}
51+
}
52+
4653
/**
4754
* Check if the HTTP error is recoverable. This will return false if a request
4855
* made with any payload could not recover. If the reason for the failure

packages/shared/common/src/utils/timedPromise.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { LDTimeoutError } from '../errors';
2+
13
/**
24
* Returns a promise which errors after t seconds.
35
*
@@ -8,7 +10,7 @@ const timedPromise = (t: number, taskName: string) =>
810
new Promise<void>((_res, reject) => {
911
setTimeout(() => {
1012
const e = `${taskName} timed out after ${t} seconds.`;
11-
reject(new Error(e));
13+
reject(new LDTimeoutError(e));
1214
}, t * 1000);
1315
});
1416

0 commit comments

Comments
 (0)