diff --git a/lib/connection.js b/lib/connection.js index 12c0b8bb12..58f024b3c7 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; @@ -445,7 +446,7 @@ class Connection extends EventEmitter { // If it's an Err Packet, we should use it. if (marker === 0xff) { const error = Packets.Error.fromPacket(packet); - this.protocolError(error.message, error.code); + this.protocolError(error.message, ErrorCodeToName[error.code]); } else { // Otherwise, it means it's some other unexpected packet. this.protocolError( diff --git a/test/integration/test-server-close.js b/test/integration/test-server-close.js index 23df672de2..4805524038 100644 --- a/test/integration/test-server-close.js +++ b/test/integration/test-server-close.js @@ -2,7 +2,6 @@ 'use strict'; -const errors = require('../../lib/constants/errors'); const common = require('../common'); const connection = common.createConnection(); const assert = require('assert'); @@ -40,5 +39,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'); });