Skip to content

Commit

Permalink
handle lookup errors when connecting
Browse files Browse the repository at this point in the history
Connect may result in lookup error, which was not handled. Solve this by
use a default error handler which returns whatever mosquitto reports.

This prevents us from missing errors.
  • Loading branch information
ncopa committed Jun 12, 2023
1 parent 46422c4 commit d1e5304
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lua-mosquitto.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,20 @@ static int mosq__pstatus(lua_State *L, int mosq_errno) {
return luaL_error(L, mosquitto_strerror(mosq_errno));
break;

case MOSQ_ERR_NO_CONN:
case MOSQ_ERR_CONN_LOST:
case MOSQ_ERR_PAYLOAD_SIZE:
case MOSQ_ERR_ERRNO:
lua_pushnil(L);
lua_pushinteger(L, mosq_errno);
lua_pushstring(L, mosquitto_strerror(mosq_errno));
lua_pushinteger(L, errno);
lua_pushstring(L, strerror(errno));
return 3;
break;

case MOSQ_ERR_ERRNO:
default:
lua_pushnil(L);
lua_pushinteger(L, errno);
lua_pushstring(L, strerror(errno));
lua_pushinteger(L, mosq_errno);
lua_pushstring(L, mosquitto_strerror(mosq_errno));
return 3;
break;

}

return 0;
Expand Down

0 comments on commit d1e5304

Please sign in to comment.