在使用datastax node.js驱动程序时,我获得了http://docs.datastax.com/en/developer/nodejs-driver-dse/1.4/api/module.errors/class.ResponseError/下记录的异常代码。
但是我找不到任何有关所有可用异常代码的文档。有人知道在哪里找到?
答案 0 :(得分:4)
我不确定代码值是否在任何地方都有详细记录,但您可以随时查看您正在使用的Cassandra版本的ExceptionCode来源。
在主干上,将错误列为:
SERVER_ERROR (0x0000),
PROTOCOL_ERROR (0x000A),
BAD_CREDENTIALS (0x0100),
// 1xx: problem during request execution
UNAVAILABLE (0x1000),
OVERLOADED (0x1001),
IS_BOOTSTRAPPING (0x1002),
TRUNCATE_ERROR (0x1003),
WRITE_TIMEOUT (0x1100),
READ_TIMEOUT (0x1200),
READ_FAILURE (0x1300),
FUNCTION_FAILURE (0x1400),
WRITE_FAILURE (0x1500),
CDC_WRITE_FAILURE (0x1600),
// 2xx: problem validating the request
SYNTAX_ERROR (0x2000),
UNAUTHORIZED (0x2100),
INVALID (0x2200),
CONFIG_ERROR (0x2300),
ALREADY_EXISTS (0x2400),
UNPREPARED (0x2500);
答案 1 :(得分:1)
驱动程序中未正确记录响应错误代码,我已为其创建了一张票证:https://datastax-oss.atlassian.net/browse/NODEJS-418
与此同时,您应该在IDE(VS Code / WebStorm)和/或look at the code上获得代码完成:
const responseErrorCodes = {
serverError: 0x0000,
protocolError: 0x000A,
badCredentials: 0x0100,
unavailableException: 0x1000,
overloaded: 0x1001,
isBootstrapping: 0x1002,
truncateError: 0x1003,
writeTimeout: 0x1100,
readTimeout: 0x1200,
readFailure: 0x1300,
functionFailure: 0x1400,
writeFailure: 0x1500,
syntaxError: 0x2000,
unauthorized: 0x2100,
invalid: 0x2200,
configError: 0x2300,
alreadyExists: 0x2400,
unprepared: 0x2500
};
要检查某个错误代码,您应该使用以下内容:
if (err.code === cassandra.types.responseErrorCodes.syntaxError) {
// ...
}