diff --git a/lib/connection.js b/lib/connection.js index 12c0b8bb12a..e28fb49d7ac 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -29,6 +29,7 @@ const Packets = require('./packets/index.js'); const Commands = require('./commands/index.js'); const ConnectionConfig = require('./connection_config.js'); const CharsetToEncoding = require('./constants/charset_encodings.js'); +const ErrorCodeToName = require('./constants/errors.js'); let _connectionId = 0; @@ -405,10 +406,10 @@ class Connection extends EventEmitter { const err = new Error(message); err.fatal = true; - err.code = code || 'PROTOCOL_ERROR'; + err.code = ErrorCodeToName[code] || 'PROTOCOL_ERROR'; this.emit('error', err); } - + get fatalError() { return this._fatalError; } diff --git a/test/integration/test-server-close.js b/test/integration/test-server-close.js index 23df672de24..fed1b9b0b10 100644 --- a/test/integration/test-server-close.js +++ b/test/integration/test-server-close.js @@ -40,5 +40,5 @@ process.on('uncaughtException', err => { process.on('exit', () => { assert.equal(error.message, 'The client was disconnected by the server because of inactivity. See wait_timeout and interactive_timeout for configuring this behavior.'); - assert.equal(error.code, errors.ER_CLIENT_INTERACTION_TIMEOUT); + assert.equal(error.code, 'ER_CLIENT_INTERACTION_TIMEOUT'); });