2 #include <SDL2/SDL_mixer.h>
10 static Error_type current_error_type = ERROR_TYPE_OK;
12 Error_type current_error(void)
14 return current_error_type;
17 void throw_error(Error_type error_type)
19 assert(0 <= error_type && error_type < ERROR_TYPE_N);
20 current_error_type = error_type;
23 void reset_error(void)
25 current_error_type = ERROR_TYPE_OK;
28 void print_current_error_msg(const char *user_prefix)
30 print_error_msg(current_error_type, user_prefix);
31 current_error_type = ERROR_TYPE_OK;
34 void print_error_msg(Error_type error_type, const char *user_prefix)
42 fprintf(stderr, "libc error: %s: %s\n", user_prefix, strerror(errno));
46 fprintf(stderr, "SDL2 error: %s: %s\n", user_prefix, SDL_GetError());
49 case ERROR_TYPE_SDL2_MIXER:
50 fprintf(stderr, "SDL2_mixer error: %s: %s\n", user_prefix, Mix_GetError());