OCT 1. 错误码未定义时返回ERR_UNKNOW

This commit is contained in:
huangxin 2023-02-07 09:28:23 +08:00
parent fa3a0be69d
commit c6f76af116
1 changed files with 10 additions and 0 deletions

View File

@ -2,6 +2,7 @@
// Created by xajhuang on 2022/12/5.
//
#include <user_errno.h>
#include "misc.h"
#define MAX_DESC_LENGTH (256)
#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) {
if (errCode >= ARRAY_SIZE(g_enumStrVal) || errCode < 0) {
return g_enumStrVal[ARRAY_SIZE(g_enumStrVal) - 1][0];
}
return g_enumStrVal[errCode][0];
}
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];
}
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];
}