diff options
author | Jo-Philipp Wich <jo@mein.io> | 2020-10-02 20:57:18 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2020-10-02 20:59:04 +0200 |
commit | 56c0a1a0647abc1f2bee1d64b92b4f25cab8290a (patch) | |
tree | 2556f7ef3ffb37d4fc5a5ec95d698a95cd766b3a /lib.c | |
parent | 1fa65ebd5506e8026277b8fd42b4d03d4b819d98 (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.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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) |