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 fb82aba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions 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 @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration/test-server-close.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

0 comments on commit fb82aba

Please sign in to comment.