38#ifndef ST_LOGGER_EXCEPT_H
39#define ST_LOGGER_EXCEPT_H
44#ifndef ST_EXCEPTIONS_EN
51#define ST_EXCEPTIONS_EN 0
63#define ST_RAISE(lvl, e) \
65 enum StTraceLvl _lvl = (lvl); \
67 if (ST_ERROR == _lvl) { \
69 ST_ERROR, NULL, "%s:%d: %s", __FILE__, \
70 __LINE__, st_except_##e.reason); \
71 if (ST_EXCEPTIONS_EN) \
73 st_except_##e.reason, __FILE__, \
75 } else if (ST_WARNING == _lvl) { \
77 ST_WARNING, NULL, "%s:%d: %s", __FILE__, \
78 __LINE__, st_except_##e.reason); \
81 ST_ERROR, NULL, "%s:%d: %s", __FILE__, \
82 __LINE__, st_except_not_supported.reason); \
95#define ST_ENSURE(cond, lvl, e) \
110#define ST_ENSURE_MEM(ptr, lvl) \
112 if ((ptr) == NULL) { \
113 ST_RAISE(lvl, null_param); \
138 = {
"Memory allocation failed."};
142 = {
"Semaphore failure."};
146 = {
"Mutex failure."};
150 = {
"Not supported."};
154 = {
"Sanity check failed."};
static const struct StException st_except_sem_fail
Exception: "sem_fail".
Definition except.h:142
static const struct StException st_except_sanity_fail
Exception: "sanity_fail".
Definition except.h:154
static const struct StException st_except_not_supported
Exception: "not_supported".
Definition except.h:150
static const struct StException st_except_alloc_fail
Exception: "alloc_fail".
Definition except.h:138
static const struct StException st_except_null_param
Exception: "null_param".
Definition except.h:134
static const struct StException st_except_mutex_fail
Exception: "mutex_fail".
Definition except.h:146
Exception.
Definition except.h:123
const char * reason
The reason that caused the exception.
Definition except.h:129