Permalink
Browse files

Fix error to string conversion for standard Lua bindings.

  • Loading branch information...
1 parent bbaa86a commit caba791908f6b428b2a387f3850264bf1e92092a @Neopallium committed Mar 22, 2012
Showing with 12 additions and 4 deletions.
  1. +6 −2 src/error.nobj.lua
  2. +6 −2 src/pre_generated-zmq.nobj.c
View
8 src/error.nobj.lua
@@ -283,12 +283,15 @@ error_code "ZMQ_Error" "int" {
ffi_is_error_check = function(rec) return "(-1 == ${" .. rec.name .. "})" end,
default = "0",
c_source [[
+ int num;
if(-1 == err) {
/* get ZErrors table. */
lua_pushlightuserdata(L, zmq_ZErrors_key);
lua_rawget(L, LUA_REGISTRYINDEX);
/* convert zmq_errno to string. */
- lua_rawgeti(L, -1, zmq_errno());
+ num = zmq_errno();
+ lua_pushinteger(L, num);
+ lua_gettable(L, -2);
/* remove ZErrors table. */
lua_remove(L, -2);
if(!lua_isnil(L, -1)) {
@@ -297,7 +300,8 @@ error_code "ZMQ_Error" "int" {
}
/* Unknown error. */
lua_pop(L, 1);
- err_str = "UNKNOWN ERROR";
+ lua_pushfstring(L, "UNKNOWN ERROR(%d)", num);
+ return;
}
]],
ffi_source [[
View
8 src/pre_generated-zmq.nobj.c
@@ -4002,12 +4002,15 @@ static int ZErrors____index__meth(lua_State *L) {
static void error_code__ZMQ_Error__push(lua_State *L, ZMQ_Error err) {
const char *err_str = NULL;
+ int num;
if(-1 == err) {
/* get ZErrors table. */
lua_pushlightuserdata(L, zmq_ZErrors_key);
lua_rawget(L, LUA_REGISTRYINDEX);
/* convert zmq_errno to string. */
- lua_rawgeti(L, -1, zmq_errno());
+ num = zmq_errno();
+ lua_pushinteger(L, num);
+ lua_gettable(L, -2);
/* remove ZErrors table. */
lua_remove(L, -2);
if(!lua_isnil(L, -1)) {
@@ -4016,7 +4019,8 @@ static void error_code__ZMQ_Error__push(lua_State *L, ZMQ_Error err) {
}
/* Unknown error. */
lua_pop(L, 1);
- err_str = "UNKNOWN ERROR";
+ lua_pushfstring(L, "UNKNOWN ERROR(%d)", num);
+ return;
}
if(err_str) {

0 comments on commit caba791

Please sign in to comment.