mirror of
https://github.com/NikitaIvanovV/ctpv.git
synced 2025-02-04 12:49:11 +01:00
Add error traceback
This commit is contained in:
parent
d590bf66ad
commit
ed265a7af6
20
src/error.h
20
src/error.h
@ -22,6 +22,22 @@
|
|||||||
#define FUNCFAILED(f, ...) \
|
#define FUNCFAILED(f, ...) \
|
||||||
PRINTINTERR(INTERRMSG f "() failed" __VA_OPT__(": %s", __VA_ARGS__))
|
PRINTINTERR(INTERRMSG f "() failed" __VA_OPT__(": %s", __VA_ARGS__))
|
||||||
|
|
||||||
|
#ifndef NO_TRACEBACK
|
||||||
|
#define ERRCHK_PRINT_(...) \
|
||||||
|
do { \
|
||||||
|
int __a = 0; \
|
||||||
|
__VA_OPT__(PRINTINTERR(__VA_ARGS__); __a = 1;) \
|
||||||
|
if (!__a) \
|
||||||
|
PRINTINTERR(); \
|
||||||
|
} while (0)
|
||||||
|
#endif
|
||||||
|
#ifdef NO_TRACEBACK
|
||||||
|
#define ERRCHK_PRINT_(...) \
|
||||||
|
do { \
|
||||||
|
__VA_OPT__(PRINTINTERR(__VA_ARGS__);) \
|
||||||
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If cond is true, return ERR. Also call print_error or
|
* If cond is true, return ERR. Also call print_error or
|
||||||
* print_errorf if error message or format string is given.
|
* print_errorf if error message or format string is given.
|
||||||
@ -29,7 +45,7 @@
|
|||||||
#define ERRCHK_RET(cond, ...) \
|
#define ERRCHK_RET(cond, ...) \
|
||||||
do { \
|
do { \
|
||||||
if (cond) { \
|
if (cond) { \
|
||||||
__VA_OPT__(PRINTINTERR(__VA_ARGS__);) \
|
ERRCHK_PRINT_(__VA_ARGS__); \
|
||||||
return ERR; \
|
return ERR; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
@ -37,7 +53,7 @@
|
|||||||
#define ERRCHK_GOTO(cond, ret, label, ...) \
|
#define ERRCHK_GOTO(cond, ret, label, ...) \
|
||||||
do { \
|
do { \
|
||||||
if (cond) { \
|
if (cond) { \
|
||||||
__VA_OPT__(PRINTINTERR(__VA_ARGS__);) \
|
ERRCHK_PRINT_(__VA_ARGS__); \
|
||||||
ret = ERR; \
|
ret = ERR; \
|
||||||
goto label; \
|
goto label; \
|
||||||
} \
|
} \
|
||||||
|
Loading…
Reference in New Issue
Block a user