XFusion API
v1.3.0
载入中...
搜索中...
未找到
xf_err_to_name.c
浏览该文件的文档.
1
12
#ifndef __XF_ERR_TO_NAME_H__
13
#define __XF_ERR_TO_NAME_H__
14
15
/* ==================== [Includes] ========================================== */
16
17
#include "
xf_common.h
"
18
19
#ifdef __cplusplus
20
extern
"C"
{
21
#endif
22
23
/* ==================== [Defines] =========================================== */
24
29
#define ERR_TBL_IT(err) {err, XSTR(err)}
30
31
/* ==================== [Typedefs] ========================================== */
32
36
typedef
struct
xf_err_msg_t
{
37
xf_err_code_t
code
;
38
const
char
*
msg
;
39
}
xf_err_msg_t
;
40
41
/* ==================== [Static Prototypes] ================================= */
42
43
/* ==================== [Static Variables] ================================== */
44
45
#if XF_COMMON_ERR_TO_NAME_LOOKUP_IS_ENABLE
46
static
const
xf_err_msg_t
xf_err_msg_table[] = {
47
ERR_TBL_IT
(
XF_FAIL
),
48
ERR_TBL_IT
(
XF_OK
),
49
50
ERR_TBL_IT
(
XF_ERR_NO_MEM
),
51
ERR_TBL_IT
(
XF_ERR_INVALID_ARG
),
52
ERR_TBL_IT
(
XF_ERR_INVALID_STATE
),
53
ERR_TBL_IT
(
XF_ERR_INVALID_CHECK
),
54
ERR_TBL_IT
(
XF_ERR_INVALID_PORT
),
55
ERR_TBL_IT
(
XF_ERR_NOT_FOUND
),
56
ERR_TBL_IT
(
XF_ERR_NOT_SUPPORTED
),
57
ERR_TBL_IT
(
XF_ERR_BUSY
),
58
ERR_TBL_IT
(
XF_ERR_TIMEOUT
),
59
ERR_TBL_IT
(
XF_ERR_UNINIT
),
60
ERR_TBL_IT
(
XF_ERR_INITED
),
61
62
ERR_TBL_IT
(
XF_ERR_RESOURCE
),
63
ERR_TBL_IT
(
XF_ERR_ISR
),
64
65
ERR_TBL_IT
(
XF_ERR_MAX
),
66
};
67
#endif
/* XF_COMMON_ERR_TO_NAME_LOOKUP_IS_ENABLE */
68
69
static
const
char
xf_unknown_msg
[] = {
70
#if XF_COMMON_ERR_TO_NAME_LOOKUP_IS_ENABLE
71
"ERROR"
,
72
#else
73
"UNKNOWN ERROR"
,
74
#endif
75
};
76
77
/* ==================== [Macros] ============================================ */
78
79
/* ==================== [Global Functions] ================================== */
80
81
const
char
*
xf_err_to_name
(
xf_err_t
code)
82
{
83
#if XF_COMMON_ERR_TO_NAME_LOOKUP_IS_ENABLE
84
unsigned
int
i = 0;
85
for
(i = 0; i < (
unsigned
int)
ARRAY_SIZE
(xf_err_msg_table); ++i) {
86
if
(xf_err_msg_table[i].code == code) {
87
return
xf_err_msg_table[i].
msg
;
88
}
89
}
90
#endif
/* XF_COMMON_ERR_TO_NAME_LOOKUP_IS_ENABLE */
91
return
xf_unknown_msg
;
92
}
93
94
/* ==================== [Static Functions] ================================== */
95
96
#ifdef __cplusplus
97
}
98
#endif
99
100
#endif
// __XF_ERR_TO_NAME_H__
xf_err_t
int32_t xf_err_t
整形错误类型。 错误码具体值见 xf_err_code_t.
Definition
xf_err.h:69
xf_err_to_name
const char * xf_err_to_name(xf_err_t code)
返回 xf_err_code_t 错误代码对应的错误信息字符串。
Definition
xf_err_to_name.c:81
xf_err_code_t
xf_err_code_t
错误类型定义。
Definition
xf_err.h:41
XF_ERR_INVALID_PORT
@ XF_ERR_INVALID_PORT
Definition
xf_err.h:49
XF_FAIL
@ XF_FAIL
Definition
xf_err.h:42
XF_ERR_INVALID_ARG
@ XF_ERR_INVALID_ARG
Definition
xf_err.h:46
XF_ERR_MAX
@ XF_ERR_MAX
Definition
xf_err.h:60
XF_ERR_NOT_SUPPORTED
@ XF_ERR_NOT_SUPPORTED
Definition
xf_err.h:51
XF_ERR_INITED
@ XF_ERR_INITED
Definition
xf_err.h:55
XF_OK
@ XF_OK
Definition
xf_err.h:43
XF_ERR_BUSY
@ XF_ERR_BUSY
Definition
xf_err.h:52
XF_ERR_RESOURCE
@ XF_ERR_RESOURCE
Definition
xf_err.h:57
XF_ERR_TIMEOUT
@ XF_ERR_TIMEOUT
Definition
xf_err.h:53
XF_ERR_INVALID_CHECK
@ XF_ERR_INVALID_CHECK
Definition
xf_err.h:48
XF_ERR_ISR
@ XF_ERR_ISR
Definition
xf_err.h:58
XF_ERR_INVALID_STATE
@ XF_ERR_INVALID_STATE
Definition
xf_err.h:47
XF_ERR_NOT_FOUND
@ XF_ERR_NOT_FOUND
Definition
xf_err.h:50
XF_ERR_UNINIT
@ XF_ERR_UNINIT
Definition
xf_err.h:54
XF_ERR_NO_MEM
@ XF_ERR_NO_MEM
Definition
xf_err.h:45
ARRAY_SIZE
#define ARRAY_SIZE(arr)
ARRAY_SIZE - 获取数组 arr 中的元素数量。
Definition
xf_predef.h:173
xf_err_msg_t
错误码和说明字符串结构体。
Definition
xf_err_to_name.c:36
xf_err_msg_t::msg
const char * msg
Definition
xf_err_to_name.c:38
xf_err_msg_t::code
xf_err_code_t code
Definition
xf_err_to_name.c:37
xf_common.h
通用头文件.
ERR_TBL_IT
#define ERR_TBL_IT(err)
Error Table Item. 错误码和说明字符串。
Definition
xf_err_to_name.c:29
xf_unknown_msg
static const char xf_unknown_msg[]
Definition
xf_err_to_name.c:69
components
xf_utils
xf_utils
src
xf_common
xf_err_to_name.c
生成于 2025年 一月 21日 星期二 17:25:09 , 为 XFusion API使用
1.9.8