summaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2016-01-09 03:49:18 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2016-01-09 05:01:50 +0100
commit53e72dd12d310c9836cf1f74a6a93b550c881655 (patch)
tree6cd7fff76f1269016d4ea1d66a36b9571cecf354 /degesch.c
parent83c14ba264a27c09b14b4a4ea77a2bd95de7b794 (diff)
downloadxK-53e72dd12d310c9836cf1f74a6a93b550c881655.tar.gz
xK-53e72dd12d310c9836cf1f74a6a93b550c881655.tar.xz
xK-53e72dd12d310c9836cf1f74a6a93b550c881655.zip
degesch: Lua: provide a traceback on load error
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/degesch.c b/degesch.c
index 3edbe15..5621f96 100644
--- a/degesch.c
+++ b/degesch.c
@@ -8632,12 +8632,17 @@ lua_plugin_load (struct app_context *ctx, const char *filename,
lua_plugin_create_meta (L, XLUA_CONNECTION_METATABLE, lua_connection_table);
lua_plugin_create_meta (L, XLUA_CONNECTOR_METATABLE, lua_connector_table);
- int ret;
- if (!(ret = luaL_loadfile (L, filename))
- && !(ret = lua_pcall (L, 0, 0, 0)))
+ struct error *error = NULL;
+ if (luaL_loadfile (L, filename))
+ error_set (e, "%s: %s", "Lua", lua_tostring (L, -1));
+ else if (!lua_plugin_call (plugin, 0, 0, &error))
+ {
+ error_set (e, "%s: %s", "Lua", error->message);
+ error_free (error);
+ }
+ else
return &plugin->super;
- error_set (e, "%s: %s", "Lua", lua_tostring (L, -1));
lua_close (L);
free (plugin);
return NULL;