From abc2583a1407593900033de8e9f4419e73cf9848 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Sat, 24 Aug 2013 06:09:54 +0200 Subject: [PATCH] Added generic default error message to exit_err(). --- src/rexit.c | 4 ++++ src/rexit.h | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/rexit.c b/src/rexit.c index 73d740b..ee71809 100644 --- a/src/rexit.c +++ b/src/rexit.c @@ -67,6 +67,10 @@ extern void exit_err(uint8_t err, struct World * world, char * msg) return; } cleanup(world); + if (NULL == msg) + { + msg = "Some error encountered. Aborted."; + } printf("%s\n", msg); exit(EXIT_FAILURE); } diff --git a/src/rexit.h b/src/rexit.h index f020485..ac85577 100644 --- a/src/rexit.h +++ b/src/rexit.h @@ -35,9 +35,10 @@ extern void exit_game(struct World * world); -/* If "err" != 0, exit with an error message "msg" and clean up. (For "err", - * pass the result of functions that return non-zero as an error status and - * thereby avoid bloating up the code with if-error-conditionals.) +/* If "err" != 0, exit with an error message "msg" and clean up. If "msg" is a + * NULL pointer, return generic error message. (For "err", pass the result of + * functions that return non-zero as an error status and thereby avoid bloating + * up the code with if-error-conditionals.) */ extern void exit_err(uint8_t err, struct World * world, char * msg); -- 2.30.2