SOHU-Co/kafka-node

Make the error code be included in the error message.

nieyuyao opened this issue · 0 comments

When an errorCode is received that is not in the ERROR_CODE , we will not know the errorCode through the error stack.

this.word32bs('partition').word16bs('errorCode').word64bs('offset').tap(function (vars) {
if (vars.errorCode) {
error = new Error(ERROR_CODE[vars.errorCode]);
} else {
topics[vars.topic][vars.partition] = vars.offset;
}

For example, if received an errorCode 82, new Error(undefined) will be thrown. Error stack is as follows,

 Error
    at Object.<anonymous> (/home/appops/approot/server/node_modules/kafka-node/lib/protocol/protocol.js:928:17)
    at Object.self.tap (/home/appops/approot/server/node_modules/binary/index.js:248:12)
    at Object.decodePartitions (/home/appops/approot/server/node_modules/kafka-node/lib/protocol/protocol.js:926:73)
    at Object.self.loop (/home/appops/approot/server/node_modules/binary/index.js:267:16)
    at Object.<anonymous> (/home/appops/approot/server/node_modules/kafka-node/lib/protocol/protocol.js:165:8)
    at Object.self.loop (/home/appops/approot/server/node_modules/binary/index.js:267:16)
    at decodeProduceV1Response (/home/appops/approot/server/node_modules/kafka-node/lib/protocol/protocol.js:920:6)
    at KafkaClient.Client.invokeResponseCallback (/home/appops/approot/server/node_modules/kafka-node/lib/baseClient.js:589:18)
    at KafkaClient.Client.handleReceivedData (/home/appops/approot/server/node_modules/kafka-node/lib/baseClient.js:569:10)
    at KafkaClient.handleReceivedData (/home/appops/approot/server/node_modules/kafka-node/lib/kafkaClient.js:1378:48)

Can make the specific error code be included in the error message?