Skip to content

Commit fb82aba

Browse files
committed
Fix error code for protocol error
1 parent fa47d0b commit fb82aba

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/connection.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const Packets = require('./packets/index.js');
2929
const Commands = require('./commands/index.js');
3030
const ConnectionConfig = require('./connection_config.js');
3131
const CharsetToEncoding = require('./constants/charset_encodings.js');
32+
const ErrorCodeToName = require('./constants/errors.js');
3233

3334
let _connectionId = 0;
3435

@@ -405,10 +406,10 @@ class Connection extends EventEmitter {
405406

406407
const err = new Error(message);
407408
err.fatal = true;
408-
err.code = code || 'PROTOCOL_ERROR';
409+
err.code = ErrorCodeToName[code] || 'PROTOCOL_ERROR';
409410
this.emit('error', err);
410411
}
411-
412+
412413
get fatalError() {
413414
return this._fatalError;
414415
}

test/integration/test-server-close.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ process.on('uncaughtException', err => {
4040

4141
process.on('exit', () => {
4242
assert.equal(error.message, 'The client was disconnected by the server because of inactivity. See wait_timeout and interactive_timeout for configuring this behavior.');
43-
assert.equal(error.code, errors.ER_CLIENT_INTERACTION_TIMEOUT);
43+
assert.equal(error.code, 'ER_CLIENT_INTERACTION_TIMEOUT');
4444
});

0 commit comments

Comments
 (0)