summaryrefslogtreecommitdiffhomepage
path: root/lib.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-10-02 20:57:18 +0200
committerJo-Philipp Wich <jo@mein.io>2020-10-02 20:59:04 +0200
commit56c0a1a0647abc1f2bee1d64b92b4f25cab8290a (patch)
tree2556f7ef3ffb37d4fc5a5ec95d698a95cd766b3a /lib.c
parent1fa65ebd5506e8026277b8fd42b4d03d4b819d98 (diff)
lib: wrap runtime exceptions in included utpl code
This is needed to preserve error context information. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib.c b/lib.c
index 9df8a62..bc7080b 100644
--- a/lib.c
+++ b/lib.c
@@ -1519,14 +1519,21 @@ ut_require_utpl(struct ut_state *s, uint32_t off, const char *path, struct json_
return ex;
}
- free(source);
-
sc = scope ? scope : xjs_new_object();
entry = ut_new_func(ut_get_op(s, s->main));
rv = ut_invoke(s, off, sc, entry, NULL);
+ if (ut_is_type(rv, T_EXCEPTION)) {
+ msg = ut_format_error(s, source);
+ ut_putval(rv);
+ rv = ut_exception(s, off, "%s", msg);
+ free(msg);
+ }
+
+ free(source);
+
json_object_put(entry);
if (sc != scope)