Added error handling Lua interface; closes #376.