Skip to content

Commit e2d503a

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

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
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-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
'use strict';
44

5-
const errors = require('../../lib/constants/errors');
65
const common = require('../common');
76
const connection = common.createConnection();
87
const assert = require('assert');
@@ -40,5 +39,5 @@ process.on('uncaughtException', err => {
4039

4140
process.on('exit', () => {
4241
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);
42+
assert.equal(error.code, 'ER_CLIENT_INTERACTION_TIMEOUT');
4443
});

0 commit comments

Comments
 (0)