forked from launchdarkly/node-server-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.js
26 lines (22 loc) · 935 Bytes
/
errors.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function createCustomError(name) {
function CustomError(message, code) {
Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
this.message = message;
this.code = code;
}
CustomError.prototype = new Error();
CustomError.prototype.name = name;
CustomError.prototype.constructor = CustomError;
return CustomError;
}
exports.LDPollingError = createCustomError('LaunchDarklyPollingError');
exports.LDStreamingError = createCustomError('LaunchDarklyStreamingError');
exports.LDUnexpectedResponseError = createCustomError('LaunchDarklyUnexpectedResponseError');
exports.LDInvalidSDKKeyError = createCustomError('LaunchDarklyInvalidSDKKeyError');
exports.LDClientError = createCustomError('LaunchDarklyClientError');
exports.isHttpErrorRecoverable = function(status) {
if (status >= 400 && status < 500) {
return status === 400 || status === 408 || status === 429;
}
return true;
}