summaryrefslogtreecommitdiff
path: root/client/errcatch.c
diff options
context:
space:
mode:
Diffstat (limited to 'client/errcatch.c')
-rw-r--r--client/errcatch.c27
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); }