Skip to content

Commit

Permalink
Fix error code for protocol error
Browse files Browse the repository at this point in the history
  • Loading branch information
KunZhou-at committed Oct 25, 2023
1 parent fa47d0b commit e047956
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
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');
});

0 comments on commit e047956

Please sign in to comment.