diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-06-06 20:48:20 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-06-06 20:48:20 +0200 |
commit | fedc13d6564dcf110ba3b7faca3c34a28c7905cb (patch) | |
tree | 422a499d46e5e63618201054218300e04ed134fe /client/errcatch.c | |
parent | ae8beb20a2a837824cfda4d748fbe07b26a161f0 (diff) |
error logging working
Diffstat (limited to 'client/errcatch.c')
-rw-r--r-- | client/errcatch.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/client/errcatch.c b/client/errcatch.c index 5e39b00..c39544c 100644 --- a/client/errcatch.c +++ b/client/errcatch.c @@ -1,18 +1,15 @@ -#include "../shared/errcatch.h" +#include <stdlib.h> -void w2_errcatch_handle_error(w2_s_error *error) { - // TODO: handle more error types - switch (error->code) { - case W2_E_WARN_UNCAUGHT_ERROR: { - break; - } - default: { - g_w2_error_uncaught = true; -#ifdef W2_SIM - simwarn("Uncaught/unhandled error found with code 0x%02x\n", error->code); -#endif - } - } +#include "errcatch.h" - return; +w2_s_error *g_w2_error_log[W2_ERRCATCH_LOG_SIZE] = {NULL}; +unsigned int g_w2_error_log_index = 0; + +void w2_errcatch_log_error(w2_s_error *error) { + if (g_w2_error_log[g_w2_error_log_index] != NULL) free(g_w2_error_log[g_w2_error_log_index]); + g_w2_error_log[g_w2_error_log_index] = + w2_alloc_error(error->code, error->message_length, error->message); + g_w2_error_log_index = (g_w2_error_log_index + 1) % W2_ERRCATCH_LOG_SIZE; } + +void w2_errcatch_handle_error(w2_s_error *error) { w2_errcatch_log_error(error); } |