From 3a6fc4c197699ca094af499ff69b495eb1446c69 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 17 Oct 2024 01:32:55 +0300 Subject: [PATCH] BAN: Add proper error messages for `MUST()` in userspace --- BAN/include/BAN/Errors.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BAN/include/BAN/Errors.h b/BAN/include/BAN/Errors.h index e0be8fa2..613deec5 100644 --- a/BAN/include/BAN/Errors.h +++ b/BAN/include/BAN/Errors.h @@ -12,9 +12,9 @@ #define MUST(expr) ({ auto&& e = expr; if (e.is_error()) Kernel::panic("{}", e.error()); e.release_value(); }) #define MUST_REF(expr) *({ auto&& e = expr; if (e.is_error()) Kernel::panic("{}", e.error()); &e.release_value(); }) #else - #include - #define MUST(expr) ({ auto&& e = expr; assert(!e.is_error()); e.release_value(); }) - #define MUST_REF(expr) *({ auto&& e = expr; assert(!e.is_error()); &e.release_value(); }) + #include + #define MUST(expr) ({ auto&& e = expr; if (e.is_error()) { derrorln("MUST(" #expr "): {}", e.error()); __builtin_trap(); } e.release_value(); }) + #define MUST_REF(expr) *({ auto&& e = expr; if (e.is_error()) { derrorln("MUST(" #expr "): {}", e.error()); __builtin_trap(); } &e.release_value(); }) #endif #define TRY(expr) ({ auto&& e = expr; if (e.is_error()) return e.release_error(); e.release_value(); })