From 8b5c4429c8d76d38a85165c6837549a50cf2b312 Mon Sep 17 00:00:00 2001 From: Quinn Date: Thu, 13 Feb 2025 15:33:23 +0100 Subject: [PATCH] fix: error really should exit immediately when called --- src/error_handling.c | 3 +++ src/error_handling.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/error_handling.c b/src/error_handling.c index 92c0659..aee0e2c 100644 --- a/src/error_handling.c +++ b/src/error_handling.c @@ -50,5 +50,8 @@ void error(gamestatus error_code, char const* fmt, ...) { write_args(buf, fmt); (void)fprintf(stderr, "\033[91mE: %s\033[0m\n", buf); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "something went wrong! :O", buf, NULL); + + // set status, but exit immediately, as code is not allowed to execute beyond this point status = error_code; + exit(status); } diff --git a/src/error_handling.h b/src/error_handling.h index 5e47d13..a5fe13e 100644 --- a/src/error_handling.h +++ b/src/error_handling.h @@ -31,4 +31,4 @@ gamestatus get_gamestatus(void); // gets the current status of the game void debug(char const*, ...); // prints a debug message to stdout if the DEBUG environment variable is set, otherwise the call is ignored. void info(char const*, ...); // prints an info message to stdout void warn(char const*, ...); // prints a warning message to stderr -void error(gamestatus, char const*, ...); // prints an error message to stderr +void error(gamestatus, char const*, ...); // prints an error message to stderr before exiting