flukso/lua-mosquitto — pull request #7 by karlp (2014-11-12 11:03:30+00:00)
Title: remove protection around user callbacks

If a user provides handlers, it's their responsibility that they are
correct. Use a lua_call instead of a lua_pcall so that errors in user
provided handlers are propagated to the user that provided the handler.

Without this, any errors in user code are simply swallowed with no
indication that they even happened. This is akin to the lua interpreter
simply ignoring errors and continuing on as if nothing had happened.

Example code:

mqtt:set_callback(mosq.ON_MESSAGE, function(mid, topic, payload, qos, retain)
print(string.format("Received mid: %d on topic: %s", mid, topic))
error("Simulate a syntax or other error inside your callback")
print(".... and, exited happily ;)")
end)

This sort of user code should produce an error, but instead it prints
the first line, and keeps running, printing out again for each message
received.

Signed-off-by: Karl Palsson