Skip to content

Commit e047956

Browse files
committed
Fix error code for protocol error
1 parent fa47d0b commit e047956

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/connection.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const Packets = require('./packets/index.js');
2929
const Commands = require('./commands/index.js');
3030
const ConnectionConfig = require('./connection_config.js');
3131
const CharsetToEncoding = require('./constants/charset_encodings.js');
32+
const ErrorCodeToName = require('./constants/errors.js');
3233

3334
let _connectionId = 0;
3435

@@ -445,7 +446,7 @@ class Connection extends EventEmitter {
445446
// If it's an Err Packet, we should use it.
446447
if (marker === 0xff) {
447448
const error = Packets.Error.fromPacket(packet);
448-
this.protocolError(error.message, error.code);
449+
this.protocolError(error.message, ErrorCodeToName[error.code]);
449450
} else {
450451
// Otherwise, it means it's some other unexpected packet.
451452
this.protocolError(

test/integration/test-server-close.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
'use strict';
44

5-
const errors = require('../../lib/constants/errors');
65
const common = require('../common');
76
const connection = common.createConnection();
87
const assert = require('assert');
@@ -40,5 +39,5 @@ process.on('uncaughtException', err => {
4039

4140
process.on('exit', () => {
4241
assert.equal(error.message, 'The client was disconnected by the server because of inactivity. See wait_timeout and interactive_timeout for configuring this behavior.');
43-
assert.equal(error.code, errors.ER_CLIENT_INTERACTION_TIMEOUT);
42+
assert.equal(error.code, 'ER_CLIENT_INTERACTION_TIMEOUT');
4443
});

0 commit comments

Comments
 (0)