Skip to content

Commit b63b26f

Browse files
committed
return error callback
1 parent cb20e46 commit b63b26f

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

client/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,17 @@ function Client(url, retryAttempts) {
2020
/** @type {Number} */
2121
this._reopenTimeout = null;
2222
/** @type {Number} */
23-
this._retryAttempts = retryAttempts || 3;;
23+
this._retryAttempts = retryAttempts || 3;
2424
/** @type {Number} */
2525
this._counter = 0;
26+
/** @type {Function} */
27+
this._errorCallback = null;
2628
}
2729

30+
Client.prototype.onCaptureError = function(callback) {
31+
this._errorCallback = callback;
32+
};
33+
2834
Client.prototype.open = function() {
2935
clearTimeout(this._reopenTimeout);
3036
this._reopenTimeout = null;
@@ -47,7 +53,9 @@ Client.prototype._reopen = function() {
4753
this._counter++;
4854
this.open();
4955
} else {
50-
throw new Error('Reached max retryAttempts');
56+
if (typeof this._errorCallback === 'function') {
57+
this._errorCallback(new Error('Reached max retryAttempts'));
58+
}
5159
}
5260
}.bind(this), 1000 * this._counter);
5361
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "socket-redis",
3-
"version": "3.3.1",
3+
"version": "3.3.3",
44
"description": "Redis to SockJS relay",
55
"main": "socket-redis.js",
66
"bin": {

0 commit comments

Comments
 (0)