From: Charles-Henri Bruyand Date: Wed, 23 May 2018 15:29:09 +0000 (+0200) Subject: luawrapper: report caught std::exception as lua_error with a nice reason message X-Git-Tag: dnsdist-1.3.1~55^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F6658%2Fhead;p=thirdparty%2Fpdns.git luawrapper: report caught std::exception as lua_error with a nice reason message --- 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);