From 5a5fb7c8b359582bb684c1389598a83c726eb73f Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Fri, 1 Feb 2013 10:55:49 +0100 Subject: foward on_state_create error to main state if any --- src/tools.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tools.c b/src/tools.c index 9961c1a..0fcb2f1 100644 --- a/src/tools.c +++ b/src/tools.c @@ -538,7 +538,11 @@ lua_State* luaG_newstate( lua_State* _from, int const _on_state_create, char con luaG_inter_move( _from, L, 1); STACK_END( _from, 0); } - lua_call( L, 0, 0); + // capture error and forward it to main state + if( lua_pcall( L, 0, 0, 0) != LUA_OK) + { + luaL_error( _from, "on_state_create failed: \"%s\"", lua_isstring( L, -1) ? lua_tostring( L, -1) : lua_typename( L, lua_type( L, -1))); + } STACK_MID( L, 0); } -- cgit v1.2.3-55-g6feb