From bf0e47f99f0ede6cbfb30c1f7aafdd2f1eca8683 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Thu, 7 Jan 2016 01:02:33 +0100 Subject: improve error messages in case loading applause.lua fails --- applause.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'applause.c') diff --git a/applause.c b/applause.c index f0e5034..99b5453 100644 --- a/applause.c +++ b/applause.c @@ -886,13 +886,17 @@ main(int argc, char **argv) luaL_openlibs(L); - if (luaL_loadfile(L, LUA_MODULE) || lua_pcall(L, 0, 0, 0)) { - /* FIXME: pop error message */ - fprintf(stderr, "Error loading Lua module %s.\n", - LUA_MODULE); + lua_pushcfunction(L, traceback); + + if (luaL_loadfile(L, LUA_MODULE) || lua_pcall(L, 0, 0, -2)) { + fprintf(stderr, "Error loading Lua module %s: %s\n", + LUA_MODULE, lua_tostring(L, -1)); exit(EXIT_FAILURE); } + /* remove traceback function */ + lua_remove(L, -1); + init_audio(buffer_size); /* -- cgit v1.2.3