OCT 1. 错误码未定义时返回ERR_UNKNOW
This commit is contained in:
parent
fa3a0be69d
commit
c6f76af116
|
@ -2,6 +2,7 @@
|
||||||
// Created by xajhuang on 2022/12/5.
|
// Created by xajhuang on 2022/12/5.
|
||||||
//
|
//
|
||||||
#include <user_errno.h>
|
#include <user_errno.h>
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
#define MAX_DESC_LENGTH (256)
|
#define MAX_DESC_LENGTH (256)
|
||||||
#define GENERATE_STRING(STRING, no, desc) {#STRING, desc},
|
#define GENERATE_STRING(STRING, no, desc) {#STRING, desc},
|
||||||
|
@ -11,13 +12,22 @@ static const char *g_enumStrVal[][MAX_DESC_LENGTH] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *getErrorEnumNameString(int errCode) {
|
const char *getErrorEnumNameString(int errCode) {
|
||||||
|
if (errCode >= ARRAY_SIZE(g_enumStrVal) || errCode < 0) {
|
||||||
|
return g_enumStrVal[ARRAY_SIZE(g_enumStrVal) - 1][0];
|
||||||
|
}
|
||||||
return g_enumStrVal[errCode][0];
|
return g_enumStrVal[errCode][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *getErrorEnumDesc(int errCode) {
|
const char *getErrorEnumDesc(int errCode) {
|
||||||
|
if (errCode >= ARRAY_SIZE(g_enumStrVal) || errCode < 0) {
|
||||||
|
return g_enumStrVal[ARRAY_SIZE(g_enumStrVal) - 1][0];
|
||||||
|
}
|
||||||
return g_enumStrVal[errCode][0];
|
return g_enumStrVal[errCode][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *getErrorEnumDescripty(int errCode) {
|
const char *getErrorEnumDescripty(int errCode) {
|
||||||
|
if (errCode >= ARRAY_SIZE(g_enumStrVal) || errCode < 0) {
|
||||||
|
return g_enumStrVal[ARRAY_SIZE(g_enumStrVal) - 1][1];
|
||||||
|
}
|
||||||
return g_enumStrVal[errCode][1];
|
return g_enumStrVal[errCode][1];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue