aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib/tables.h
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-09-01 12:43:08 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-09-01 12:43:08 -0400
commit0a7062e2d711b5ac7fb71e873f293a8f0d0e8bc6 (patch)
tree912ae69dd9906dee11424433ff5367237296b0f6 /src/stdlib/tables.h
parent5fc7577b5a3bc2c445522dfd5b287e1c6eddc3e9 (diff)
Improved error messages
Diffstat (limited to 'src/stdlib/tables.h')
-rw-r--r--src/stdlib/tables.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/stdlib/tables.h b/src/stdlib/tables.h
index 208bf6b2..129aa5ec 100644
--- a/src/stdlib/tables.h
+++ b/src/stdlib/tables.h
@@ -49,6 +49,18 @@ void *Table$get(Table_t t, const void *key, const TypeInfo_t *type);
val_t *nonnull_var = Table$get(t, &k, info_expr); \
nonnull_var ? nonnull_expr : null_expr; \
})
+#define Table$get_checked(table_expr, key_t, val_t, key_expr, start, end, info_expr) \
+ ({ \
+ const Table_t t = table_expr; \
+ const key_t key = key_expr; \
+ const TypeInfo_t *info = info_expr; \
+ val_t *value = Table$get(t, &key, info); \
+ if (unlikely(value == NULL)) \
+ fail_source(__SOURCE_FILE__, start, end, \
+ "This key was not found in the table: ", generic_as_text(&key, false, info->TableInfo.key), \
+ "\n"); \
+ *value; \
+ })
#define Table$get_or_setdefault(table_expr, key_t, val_t, key_expr, default_expr, info_expr) \
({ \
Table_t *t = table_expr; \