commit 21de801e8d5476c8559240437fec11b3f27ca120
parent ea7745e181a0c230dff109fd6a30ddc4adc0a62c
Author: Robert Russell <robertrussell.72001@gmail.com>
Date: Wed, 15 Mar 2023 13:52:52 -0700
Remove stupid error module
The project I added it for ended up doing something else anyway.
Unfortunately error handling in C just inherently sucks.
Diffstat:
2 files changed, 0 insertions(+), 61 deletions(-)
diff --git a/inc/error.h b/inc/error.h
@@ -1,34 +0,0 @@
-#pragma once
-
-#include "def.h"
-
-#define R_ERR(e) ((e).code != 0)
-
-typedef struct RError RError;
-typedef struct RErrorSource RErrorSource;
-
-struct RErrorSource {
- char *name;
- /* Convert err to a string and write the result to buf, which must have
- * length len >= 128. If the string does not fit in the given buffer,
- * truncate in a source-specific manner (e.g., append an ellipsis). */
- void (*to_string)(char *buf, usize len, RError err);
- /* Free any data associated with err. This field can be NULL. */
- void (*free)(RError err);
-};
-
-struct RError {
- int code; /* 0 iff success */
- RErrorSource *src;
- union {
- i64 i;
- u64 u;
- double f;
- char *s;
- void *p;
- } u; /* Subject to source-specific semantics. */
-};
-
-void r_error_string(char *buf, usize len, RError err);
-void r_error_fatal(RError err);
-void r_error_drop(RError err);
diff --git a/src/error.c b/src/error.c
@@ -1,27 +0,0 @@
-#include <assert.h>
-
-#include "error.h"
-#include "log.h"
-#include "rcx.h"
-
-void
-r_error_string(char *buf, usize len, RError err) {
- assert(len >= 128);
- err.src->to_string(buf, len, err);
-}
-
-void
-r_error_fatal(RError err) {
- if (R_ERR(err)) {
- char buf[128];
- r_error_string(buf, sizeof buf, err);
- r_fatalf("%s", buf);
- }
-}
-
-void
-r_error_drop(RError err) {
- if (R_ERR(err)) {
- err.src->free(err);
- }
-}