Fixed feedback error handling.
Only emit `error` in the event of an unrecoverable error (Being unable to load certificates/keys from disk) In other instances emit `feedbackError`
This commit is contained in:
Родитель
9ad22df77a
Коммит
59ec4ba9cf
|
@ -77,7 +77,7 @@ function Feedback(options) {
|
|||
if (typeof this.options.feedback == 'function') {
|
||||
this.on('feedback', this.options.feedback);
|
||||
}
|
||||
|
||||
|
||||
process.nextTick(function() {
|
||||
if(this.listeners('feedback').length === 0) {
|
||||
debug("WARNING: A `feedback` listener has not been specified. Data may be lost.");
|
||||
|
@ -199,6 +199,7 @@ Feedback.prototype.connect = function () {
|
|||
this.socket.once('close', this.resetConnection.bind(this));
|
||||
}.bind(this)).fail(function (error) {
|
||||
debug("Module initialisation error:", error);
|
||||
this.emit('error', error);
|
||||
this.deferredConnection.reject(error);
|
||||
this.deferredConnection = null;
|
||||
}.bind(this));
|
||||
|
@ -246,7 +247,7 @@ Feedback.prototype.receive = function (data) {
|
|||
Feedback.prototype.destroyConnection = function (err) {
|
||||
debug("Destroying connection");
|
||||
if(err) {
|
||||
this.emit('error', err);
|
||||
this.emit('feedbackError', err);
|
||||
}
|
||||
if (this.socket) {
|
||||
this.socket.destroySoon();
|
||||
|
@ -293,7 +294,7 @@ Feedback.prototype.start = function () {
|
|||
Feedback.prototype.request = function () {
|
||||
debug("Performing feedback request");
|
||||
this.connect().fail(function (error) {
|
||||
this.emit('error', error);
|
||||
this.emit('feedbackError');
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче