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
20extern "C" {
21#endif
22
23/* ==================== [Defines] =========================================== */
24
29#define ERR_TBL_IT(err) {err, XSTR(err)}
30
31/* ==================== [Typedefs] ========================================== */
32
36typedef struct xf_err_msg_t {
38 const char *msg;
40
41/* ==================== [Static Prototypes] ================================= */
42
43/* ==================== [Static Variables] ================================== */
44
45#if XF_COMMON_ERR_TO_NAME_LOOKUP_IS_ENABLE
46static const xf_err_msg_t xf_err_msg_table[] = {
49
61
64
66};
67#endif /* XF_COMMON_ERR_TO_NAME_LOOKUP_IS_ENABLE */
68
69static 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
81const 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__
int32_t xf_err_t
整形错误类型。 错误码具体值见 xf_err_code_t.
Definition xf_err.h:69
const char * xf_err_to_name(xf_err_t code)
返回 xf_err_code_t 错误代码对应的错误信息字符串。
xf_err_code_t
错误类型定义。
Definition xf_err.h:41
@ XF_ERR_INVALID_PORT
Definition xf_err.h:49
@ XF_FAIL
Definition xf_err.h:42
@ XF_ERR_INVALID_ARG
Definition xf_err.h:46
@ XF_ERR_MAX
Definition xf_err.h:60
@ XF_ERR_NOT_SUPPORTED
Definition xf_err.h:51
@ XF_ERR_INITED
Definition xf_err.h:55
@ XF_OK
Definition xf_err.h:43
@ XF_ERR_BUSY
Definition xf_err.h:52
@ XF_ERR_RESOURCE
Definition xf_err.h:57
@ XF_ERR_TIMEOUT
Definition xf_err.h:53
@ XF_ERR_INVALID_CHECK
Definition xf_err.h:48
@ XF_ERR_ISR
Definition xf_err.h:58
@ XF_ERR_INVALID_STATE
Definition xf_err.h:47
@ XF_ERR_NOT_FOUND
Definition xf_err.h:50
@ XF_ERR_UNINIT
Definition xf_err.h:54
@ XF_ERR_NO_MEM
Definition xf_err.h:45
#define ARRAY_SIZE(arr)
ARRAY_SIZE - 获取数组 arr 中的元素数量。
Definition xf_predef.h:173
错误码和说明字符串结构体。
const char * msg
xf_err_code_t code
通用头文件.
#define ERR_TBL_IT(err)
Error Table Item. 错误码和说明字符串。
static const char xf_unknown_msg[]