Merge pull request #28959 from taosdata/enh/TD-33054-3.0

taos-CLI add error code in  error prompt text
This commit is contained in:
Shengliang Guan 2024-11-28 19:56:05 +08:00 committed by GitHub
commit 8b7e8140c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 4 deletions

View File

@ -48,6 +48,7 @@
#define SHELL_FLOAT_WIDTH 20
#define SHELL_DOUBLE_WIDTH 25
#define ERROR_CODE_DETAIL "\r\n\r\nTo view possible causes and suggested actions for error codes, see \r\n\"Error Code Reference\" in the TDengine online documentation.\r\n"
typedef struct {
char* hist[SHELL_MAX_HISTORY_SIZE];
char file[TSDB_FILENAME_LEN];

View File

@ -662,6 +662,7 @@ void showHelp() {
now - current time \n\
Example : \n\
select * from t1 where ts > now - 2w + 3d and ts <= now - 1w -2h ;\n");
printf(ERROR_CODE_DETAIL);
printf("\n");
}

View File

@ -1091,7 +1091,7 @@ void shellCleanupHistory() {
void shellPrintError(TAOS_RES *tres, int64_t st) {
int64_t et = taosGetTimestampUs();
fprintf(stderr, "\r\nDB error: %s (%.6fs)\r\n", taos_errstr(tres), (et - st) / 1E6);
fprintf(stderr, "\r\nDB error: %s[0x%08X] (%.6fs)\r\n", taos_errstr(tres), taos_errno(tres), (et - st) / 1E6);
taos_free_result(tres);
}
@ -1303,6 +1303,8 @@ int32_t shellExecute() {
#ifdef WEBSOCKET
if (shell.args.restful || shell.args.cloud) {
if (shell_conn_ws_server(1)) {
printf("failed to connect to server, reason: %s[0x%08X]\n%s", ws_errstr(NULL), ws_errno(NULL), ERROR_CODE_DETAIL);
fflush(stdout);
return -1;
}
} else {
@ -1314,7 +1316,7 @@ int32_t shellExecute() {
}
if (shell.conn == NULL) {
printf("failed to connect to server, reason: %s\n", taos_errstr(NULL));
printf("failed to connect to server, reason: %s[0x%08X]\n%s", taos_errstr(NULL), taos_errno(NULL), ERROR_CODE_DETAIL);
fflush(stdout);
return -1;
}

View File

@ -286,8 +286,8 @@ void shellRunSingleCommandWebsocketImp(char *command) {
// if it's not a ws connection error
if (TSDB_CODE_WS_DSN_ERROR != (code&TSDB_CODE_WS_DSN_ERROR)) {
et = taosGetTimestampUs();
fprintf(stderr, "\nDB: error: %s (%.6fs)\n",
ws_errstr(res), (et - st)/1E6);
fprintf(stderr, "\nDB: error:0x%08X %s (%.6fs)\n",
ws_errno(res), ws_errstr(res), (et - st)/1E6);
ws_free_result(res);
return;
}