diff --git a/src/error.c b/src/error.c index 3fba05e..61da4d8 100644 --- a/src/error.c +++ b/src/error.c @@ -3,6 +3,8 @@ #include "error.h" #include "utils.h" +int err_internal_error = 0; + void print_error(const char *error_msg) { /* We print errors to stdout because lf file manager diff --git a/src/error.h b/src/error.h index 4b26efd..261f681 100644 --- a/src/error.h +++ b/src/error.h @@ -23,12 +23,12 @@ 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(); \ +#define ERRCHK_PRINT_(...) \ + do { \ + int __a = 0; \ + __VA_OPT__(PRINTINTERR(__VA_ARGS__); __a = err_internal_error = 1;) \ + if (!__a && err_internal_error) \ + PRINTINTERR(); \ } while (0) #endif #ifdef NO_TRACEBACK @@ -78,6 +78,8 @@ #define ERRCHK_RET_OK(e) ERRCHK_RET((e) != OK) #define ERRCHK_GOTO_OK(e, r, l) ERRCHK_GOTO((e) != OK, r, l) +extern int err_internal_error; + enum { OK, ERR,