Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error code for protocol error #2259

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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(
Expand Down
3 changes: 1 addition & 2 deletions test/integration/test-server-close.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

'use strict';

const errors = require('../../lib/constants/errors');
const common = require('../common');
const connection = common.createConnection();
const assert = require('assert');
Expand Down Expand Up @@ -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');
});
Loading