Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/shared/common/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ export class LDClientError extends Error {
}
}

export class LDTimeoutError extends Error {
constructor(message: string) {
super(message);
this.name = 'LaunchDarklyTimeoutError';
}
}

/**
* Check if the HTTP error is recoverable. This will return false if a request
* made with any payload could not recover. If the reason for the failure
Expand Down
4 changes: 3 additions & 1 deletion packages/shared/common/src/utils/timedPromise.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { LDTimeoutError } from '../errors';

/**
* Returns a promise which errors after t seconds.
*
Expand All @@ -8,7 +10,7 @@ const timedPromise = (t: number, taskName: string) =>
new Promise<void>((_res, reject) => {
setTimeout(() => {
const e = `${taskName} timed out after ${t} seconds.`;
reject(new Error(e));
reject(new LDTimeoutError(e));
}, t * 1000);
});

Expand Down