Skip to content

Commit 7459d1c

Browse files
committed
Rename _connectionErrorHandler -> _onError
1 parent af0677d commit 7459d1c

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

lib/Client.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Client.prototype._connect = function() {
5858
var self = this;
5959

6060
socket
61-
.on('error', this._connectionErrorHandler.bind(this))
61+
.on('error', this._onError.bind(this))
6262
.on('data', parser.write.bind(parser))
6363
.on('end', this._onEnd.bind(this))
6464
.connect(this.port, this.host);
@@ -238,7 +238,7 @@ Client.prototype._handlePacket = function(packet) {
238238
return;
239239
}
240240

241-
this._connectionErrorHandler(Client._packetToUserObject(packet));
241+
this._onError(Client._packetToUserObject(packet));
242242
return;
243243
}
244244

@@ -270,31 +270,6 @@ Client.prototype._handlePacket = function(packet) {
270270
this._dequeue();
271271
};
272272

273-
Client.prototype._connectionErrorHandler = function(err) {
274-
this.destroy();
275-
276-
var task = this._queue[0];
277-
var delegate = (task)
278-
? task.delegate
279-
: null;
280-
281-
if (delegate instanceof Query) {
282-
delegate.emit('error', err);
283-
return;
284-
}
285-
286-
if (!delegate) {
287-
this.emit('error', err);
288-
} else {
289-
delegate(err);
290-
this._queue.shift();
291-
}
292-
293-
if (this._queue.length) {
294-
this._connect();
295-
}
296-
};
297-
298273
Client.prototype._sendAuth = function(greeting) {
299274
var token = auth.token(this.password, greeting.scrambleBuffer);
300275
var packetSize = (
@@ -360,6 +335,31 @@ Client.prototype._sendOldAuth = function(greeting) {
360335
this.write(packet);
361336
};
362337

338+
Client.prototype._onError = function(err) {
339+
this.destroy();
340+
341+
var task = this._queue[0];
342+
var delegate = (task)
343+
? task.delegate
344+
: null;
345+
346+
if (delegate instanceof Query) {
347+
delegate.emit('error', err);
348+
return;
349+
}
350+
351+
if (!delegate) {
352+
this.emit('error', err);
353+
} else {
354+
delegate(err);
355+
this._queue.shift();
356+
}
357+
358+
if (this._queue.length) {
359+
this._connect();
360+
}
361+
};
362+
363363
Client.prototype._onEnd = function() {
364364
if (this.ending) {
365365
// @todo destroy()?

0 commit comments

Comments
 (0)