summaryrefslogtreecommitdiff
path: root/src/anylike.c
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anylike.org>2009-12-25 15:36:39 +0000
committerChristian Pointner <equinox@anylike.org>2009-12-25 15:36:39 +0000
commitd148e7d1e14949f2565a4765eba1113fae449ebb (patch)
tree3afc10c99c77a4ff342cb20d9b4866cb85518e84 /src/anylike.c
parentluaL_error instead of lua_error (diff)
moved from useless checklstring to checkstring
getting error message from stack at loadfile and call
Diffstat (limited to 'src/anylike.c')
-rw-r--r--src/anylike.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/anylike.c b/src/anylike.c
index ef0669b..c6e39d7 100644
--- a/src/anylike.c
+++ b/src/anylike.c
@@ -107,11 +107,12 @@ int main_loop(options_t* opt)
int ret = luaL_loadfile(L, LUA_MAIN_LOOP);
if(ret) {
+ const char* err_str = luaL_checkstring(L, -1);
switch(ret) {
- case LUA_ERRSYNTAX: log_printf(ERROR, "luaL_loadfile(%s): syntax error during pre-compilation", LUA_MAIN_LOOP); break;
- case LUA_ERRMEM: log_printf(ERROR, "luaL_loadfile(%s): memory allocation error", LUA_MAIN_LOOP); break;
- case LUA_ERRFILE: log_printf(ERROR, "luaL_loadfile(%s): file access error", LUA_MAIN_LOOP); break;
- default: log_printf(ERROR, "luaL_loadfile(%s): unknown error", LUA_MAIN_LOOP); break;
+ case LUA_ERRSYNTAX: log_printf(ERROR, "luaL_loadfile(%s) syntax error: %s", LUA_MAIN_LOOP, err_str); break;
+ case LUA_ERRMEM: log_printf(ERROR, "luaL_loadfile(%s) malloc error: %s", LUA_MAIN_LOOP, err_str); break;
+ case LUA_ERRFILE: log_printf(ERROR, "luaL_loadfile(%s) file access error: %s", LUA_MAIN_LOOP, err_str); break;
+ default: log_printf(ERROR, "luaL_loadfile(%s) unknown error: %s", LUA_MAIN_LOOP, err_str); break;
}
lua_close(L);
return -1;
@@ -119,15 +120,19 @@ int main_loop(options_t* opt)
ret = lua_pcall(L, 0, LUA_MULTRET, 0);
if(ret) {
+ const char* err_str = luaL_checkstring(L, -1);
switch(ret) {
- case LUA_ERRRUN: log_printf(ERROR, "lua_pcall(): runtime error"); break;
- case LUA_ERRMEM: log_printf(ERROR, "lua_pcall(): memory allocation error"); break;
- case LUA_ERRERR: log_printf(ERROR, "lua_pcall(): error while running the error handler function"); break;
+ case LUA_ERRRUN: log_printf(ERROR, "lua_pcall() runtime error: %s", err_str); break;
+ case LUA_ERRMEM: log_printf(ERROR, "lua_pcall() malloc error: %s", err_str); break;
+ case LUA_ERRERR: log_printf(ERROR, "lua_pcall() error at error handler function: %s", err_str); break;
}
lua_close(L);
return -1;
}
+
+
+
lua_close(L);
return 0;
}