Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect a runtime error in a UserdataMetatable function call #65

Closed
TimSC opened this issue Jun 27, 2017 · 1 comment
Closed

Detect a runtime error in a UserdataMetatable function call #65

TimSC opened this issue Jun 27, 2017 · 1 comment

Comments

@TimSC
Copy link

TimSC commented Jun 27, 2017

I would like to detect runtime errors when I call a lua function. I tried this, (similar to https://github.com/satoren/kaguya/blob/master/test/test_06_state.cpp ) but no exception is thrown.

luaState.setErrorHandler(kaguya::ErrorHandler::throwDefaultError);
kaguya::LuaFunction way_function = luaState["way_function"];
kaguya::LuaRef ret = way_function(&sharedData.osmObject);

I have a deliberate error in the lua code which I would expect to say variable not defined:

function way_function(way)
	local highway = way:Find("highway")
	local waterway = way:Find("waterway")
	if highway~="" then
		way:Layer("transportation", false)
		way:Attribute("class", highway)
	end
	if waterway~="" then
		way:Layer("waterway", false)
		way:Attribute("class", waterway)
	end
	if building~="" then
		way:Layer("building", true)
	end
end

Any ideas?

@TimSC
Copy link
Author

TimSC commented Jun 27, 2017

"In Lua programs, typos in variable names can be hard to spot because, in general, Lua will not complain that a variable is undefined." Interesting language! That's news to me. http://lua-users.org/wiki/DetectingUndefinedVariables

@TimSC TimSC closed this as completed Jun 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant