From fedc13d6564dcf110ba3b7faca3c34a28c7905cb Mon Sep 17 00:00:00 2001 From: lonkaars Date: Mon, 6 Jun 2022 20:48:20 +0200 Subject: error logging working --- client/errcatch.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'client/errcatch.c') 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 -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); } -- cgit v1.2.3