enh: change redirect to network_unavail

This commit is contained in:
yihaoDeng 2022-07-16 14:58:55 +08:00
parent 684b550f5e
commit 9ea66e08af
1 changed files with 4 additions and 0 deletions

View File

@ -142,6 +142,7 @@ void taos_close(TAOS *taos) {
int taos_errno(TAOS_RES *res) { int taos_errno(TAOS_RES *res) {
if (res == NULL || TD_RES_TMQ_META(res)) { if (res == NULL || TD_RES_TMQ_META(res)) {
if (terrno == TSDB_CODE_RPC_REDIRECT) errno = TSDB_CODE_RPC_NETWORK_UNAVAIL;
return terrno; return terrno;
} }
@ -149,11 +150,13 @@ int taos_errno(TAOS_RES *res) {
return 0; return 0;
} }
if (pRequest->code == TSDB_CODE_RPC_REDIRECT) pRequest->code = TSDB_CODE_RPC_NETWORK_UNAVAIL;
return ((SRequestObj *)res)->code; return ((SRequestObj *)res)->code;
} }
const char *taos_errstr(TAOS_RES *res) { const char *taos_errstr(TAOS_RES *res) {
if (res == NULL || TD_RES_TMQ_META(res)) { if (res == NULL || TD_RES_TMQ_META(res)) {
if (terrno == TSDB_CODE_RPC_REDIRECT) errno = TSDB_CODE_RPC_NETWORK_UNAVAIL;
return (const char *)tstrerror(terrno); return (const char *)tstrerror(terrno);
} }
@ -165,6 +168,7 @@ const char *taos_errstr(TAOS_RES *res) {
if (NULL != pRequest->msgBuf && (strlen(pRequest->msgBuf) > 0 || pRequest->code == TSDB_CODE_RPC_FQDN_ERROR)) { if (NULL != pRequest->msgBuf && (strlen(pRequest->msgBuf) > 0 || pRequest->code == TSDB_CODE_RPC_FQDN_ERROR)) {
return pRequest->msgBuf; return pRequest->msgBuf;
} else { } else {
if (pRequest->code == TSDB_CODE_RPC_REDIRECT) pRequest->code = TSDB_CODE_RPC_NETWORK_UNAVAIL;
return (const char *)tstrerror(pRequest->code); return (const char *)tstrerror(pRequest->code);
} }
} }