src/spbot/nexus_lua.c
branchnew-lib-errors
changeset 219 cefec18b8268
parent 218 5229a5d098b2
--- a/src/spbot/nexus_lua.c	Thu May 28 00:35:02 2009 +0300
+++ b/src/spbot/nexus_lua.c	Thu May 28 01:17:36 2009 +0300
@@ -1,5 +1,5 @@
 #include "nexus_lua.h"
-#include "../lua_objs.h"
+#include "lua_objs.h"
 #include "../lua_irc.h"
 
 #include <stdlib.h>
@@ -37,14 +37,14 @@
 
     // alloc
     if ((lua = calloc(1, sizeof(*lua))) == NULL)
-        return SET_ERROR(err, ERR_CALLOC);
+        return SET_ERROR_MEM(err);
 
     // store
     lua->nexus = nexus;
 
     // create the lua state
     if ((lua->st = luaL_newstate()) == NULL)
-        JUMP_SET_ERROR(err, ERR_LUA_MEM);
+        JUMP_SET_ERROR(err, &lua_errors, ERR_LUA_MEM);
     
     // init in protected mode
     if (nexus_lua_error(lua->st, lua_cpcall(lua->st, &nexus_lua_init, lua), err))
@@ -74,7 +74,7 @@
     int ret;
     bool loaded = false;
 
-    RESET_ERROR(err);
+    error_reset(err);
 
     // load the line as a lua function
     if ((ret = luaL_loadstring(lua->st, chunk)))
@@ -105,13 +105,13 @@
     const char *error = lua_tostring(L, -1);
 
     switch (ret) {
-        case 0:                 RETURN_SET_ERROR(err, SUCCESS);
-        case LUA_ERRSYNTAX:     RETURN_SET_ERROR_STR(err, ERR_LUA_SYNTAX, error);
-        case LUA_ERRRUN:        RETURN_SET_ERROR_STR(err, ERR_LUA_RUN, error);
-        case LUA_ERRMEM:        RETURN_SET_ERROR_STR(err, ERR_LUA_MEM, error);
-        case LUA_ERRERR:        RETURN_SET_ERROR_STR(err, ERR_LUA_ERR, error);
-        case LUA_ERRFILE:       RETURN_SET_ERROR_STR(err, ERR_LUA_FILE, error);
-        default:                RETURN_SET_ERROR_EXTRA(err, ERR_UNKNOWN, ret);
+        case 0:                 return SUCCESS;
+        case LUA_ERRSYNTAX:     return SET_ERROR_STR(err, &lua_errors, ERR_LUA_SYNTAX, error);
+        case LUA_ERRRUN:        return SET_ERROR_STR(err, &lua_errors, ERR_LUA_RUN, error);
+        case LUA_ERRMEM:        return SET_ERROR_STR(err, &lua_errors, ERR_LUA_MEM, error);
+        case LUA_ERRERR:        return SET_ERROR_STR(err, &lua_errors, ERR_LUA_ERR, error);
+        case LUA_ERRFILE:       return SET_ERROR_STR(err, &lua_errors, ERR_LUA_FILE, error);
+        default:                return SET_ERROR(err, &general_errors, ERR_UNKNOWN);
     };
 }