refact error code

This commit is contained in:
Hongze Cheng 2024-07-05 14:56:42 +08:00
parent 9c5dbab91e
commit d08cd42c8a
2 changed files with 12 additions and 10 deletions

View File

@ -18,6 +18,8 @@
#include <stdint.h> #include <stdint.h>
#include "osDef.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -46,11 +48,11 @@ const char* terrstr();
char* taosGetErrMsgReturn(); char* taosGetErrMsgReturn();
char* taosGetErrMsg(); char* taosGetErrMsg();
int32_t* taosGetErrno(); int32_t* taosGetErrno();
int32_t* taosGetErrln();
int32_t taosGetErrSize(); int32_t taosGetErrSize();
#define terrno (*taosGetErrno())
#define terrln (*taosGetErrln()) extern threadlocal int32_t terrno;
#define terrMsg (taosGetErrMsg()) extern threadlocal int32_t terrln;
extern threadlocal char terrMsg[ERR_MSG_LEN];
#define SET_ERROR_MSG(MSG, ...) \ #define SET_ERROR_MSG(MSG, ...) \
snprintf(terrMsg, ERR_MSG_LEN, MSG, ##__VA_ARGS__) snprintf(terrMsg, ERR_MSG_LEN, MSG, ##__VA_ARGS__)

View File

@ -21,14 +21,14 @@
#define TAOS_ERROR_C #define TAOS_ERROR_C
static threadlocal int32_t tsErrno; threadlocal int32_t terrno;
static threadlocal int32_t tsErrln; threadlocal int32_t terrln;
static threadlocal char tsErrMsgDetail[ERR_MSG_LEN] = {0}; threadlocal char terrMsg[ERR_MSG_LEN];
static threadlocal char tsErrMsgReturn[ERR_MSG_LEN] = {0}; static threadlocal char tsErrMsgReturn[ERR_MSG_LEN] = {0};
int32_t* taosGetErrno() { return &tsErrno; } int32_t* taosGetErrno() { return &terrno; }
int32_t* taosGetErrln() { return &tsErrln; } char* taosGetErrMsg() { return terrMsg; }
char* taosGetErrMsg() { return tsErrMsgDetail; }
char* taosGetErrMsgReturn() { return tsErrMsgReturn; } char* taosGetErrMsgReturn() { return tsErrMsgReturn; }
#ifdef TAOS_ERROR_C #ifdef TAOS_ERROR_C