From 70e79d417c5ad0aaf21c7d1c5409ddf899649d50 Mon Sep 17 00:00:00 2001 From: Nikita Ivanov Date: Sun, 19 Jun 2022 15:57:17 +0500 Subject: [PATCH] Fix: print traceback only on internal error --- src/error.c | 2 ++ src/error.h | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) 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,