mirror of
https://github.com/thepigeongenerator/tetris_clone
synced 2026-02-08 07:33:34 +01:00
touchups on the new error files
This commit is contained in:
@@ -52,17 +52,17 @@ void warn(char const* fmt, ...) {
|
|||||||
void error(char const* fmt, ...) {
|
void error(char const* fmt, ...) {
|
||||||
char buf[PRINT_BUFFER_SIZE] = {0};
|
char buf[PRINT_BUFFER_SIZE] = {0};
|
||||||
write_args(buf, fmt);
|
write_args(buf, fmt);
|
||||||
(void)fprintf(stderr, "\033[mW: %s\033[0m", buf);
|
(void)fprintf(stderr, "\033[mE: %s\033[0m", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
noreturn void fatal(gamestatus error_code, char const* fname, uint32_t ln, char const* fmt, ...) {
|
noreturn void fatal(gamestatus error_code, char const* fmt, ...) {
|
||||||
char buf1[PRINT_BUFFER_SIZE] = {0};
|
char buf1[PRINT_BUFFER_SIZE] = {0};
|
||||||
write_args(buf1, fmt);
|
write_args(buf1, fmt);
|
||||||
|
|
||||||
char buf2[PRINT_BUFFER_SIZE * 2] = {0};
|
char buf2[PRINT_BUFFER_SIZE * 2] = {0};
|
||||||
sprintf(buf2, "%s\n at %s:%u (exitcode: %u)", buf1, fname, ln, error_code);
|
sprintf(buf2, "%s\nexitcode: %u", buf1, error_code);
|
||||||
|
|
||||||
(void)fprintf(stderr, "\033[91mE: %s\033[0m\n", buf2);
|
(void)fprintf(stderr, "\033[101mF: %s\033[0m\n", buf2);
|
||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "something went wrong! :O", buf2, NULL);
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "something went wrong! :O", buf2, NULL);
|
||||||
|
|
||||||
// set status, but exit immediately, as code is not allowed to execute beyond this point
|
// set status, but exit immediately, as code is not allowed to execute beyond this point
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
/* defines statuses in the 0..127, any higher/negative values are POSIX-reserved.
|
/* defines statuses in the 0..127, any higher/negative values are POSIX-reserved.
|
||||||
* The max value (or -1) shall mean the application is running, anything else shall mean an exit code of some kind */
|
* The max value (or -1) shall mean the application is running, anything else shall mean an exit code of some kind */
|
||||||
enum {
|
enum gamestatus {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
STATUS_SUCCESS = 0, // 0; successful exit
|
STATUS_SUCCESS = 0, // 0; successful exit
|
||||||
STATUS_ERROR = 1, // miscellaneous error
|
STATUS_ERROR = 1, // miscellaneous error
|
||||||
@@ -36,4 +36,4 @@ void warn(char const*, ...); // prints a warning message to stderr
|
|||||||
void error(char const*, ...); // prints an warning message to stderr
|
void error(char const*, ...); // prints an warning message to stderr
|
||||||
|
|
||||||
// prints an error message to stderr before exiting
|
// prints an error message to stderr before exiting
|
||||||
noreturn void fatal(gamestatus, char const* file_name, uint32_t line, char const* fmt, ...);
|
noreturn void fatal(gamestatus, char const* fmt, ...);
|
||||||
|
|||||||
Reference in New Issue
Block a user