From a36609d10ab4776a7a214f28c1e7ff34c3e03e32 Mon Sep 17 00:00:00 2001 From: Charles-Henri Bruyand Date: Wed, 23 May 2018 17:29:09 +0200 Subject: [PATCH] luawrapper: report caught std::exception as lua_error with a nice reason message --- ext/luawrapper/include/LuaContext.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ext/luawrapper/include/LuaContext.hpp b/ext/luawrapper/include/LuaContext.hpp index 8075aea798..fd22605c48 100644 --- a/ext/luawrapper/include/LuaContext.hpp +++ b/ext/luawrapper/include/LuaContext.hpp @@ -2366,9 +2366,15 @@ private: lua_pushstring(state, ex.luaType.c_str()); lua_pushstring(state, " to "); lua_pushstring(state, ex.destination.name()); - lua_concat(state, 4); + lua_concat(state, 5); luaError(state); + } catch (const std::exception& e) { + luaL_where(state, 1); + lua_pushstring(state, "Caught exception: "); + lua_pushstring(state, e.what()); + lua_concat(state, 3); + luaError(state); } catch (...) { Pusher::push(state, std::current_exception()).release(); luaError(state); -- 2.47.2