From eab87c0827bac8c9bdd6b67c7c7dcb7157d62abf Mon Sep 17 00:00:00 2001 From: Daniel Patterson Date: Thu, 21 May 2015 15:39:23 -0700 Subject: [PATCH] Return error message when lua error occurs. The error may not be the first item in the stack while we're inside the error handler. ::from_stack() works OK outside the error callback, but not inside. --- extractor/restriction_parser.cpp | 2 +- extractor/scripting_environment.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extractor/restriction_parser.cpp b/extractor/restriction_parser.cpp index 77dae9ce3a9..9b209b71991 100644 --- a/extractor/restriction_parser.cpp +++ b/extractor/restriction_parser.cpp @@ -44,7 +44,7 @@ namespace { int lua_error_callback(lua_State *lua_state) { - luabind::object error_msg(luabind::from_stack(lua_state, -1)); + std::string error_msg = lua_tostring(lua_state, -1); std::ostringstream error_stream; error_stream << error_msg; throw osrm::exception("ERROR occured in profile script:\n" + error_stream.str()); diff --git a/extractor/scripting_environment.cpp b/extractor/scripting_environment.cpp index 972772246ae..b32ab4b2591 100644 --- a/extractor/scripting_environment.cpp +++ b/extractor/scripting_environment.cpp @@ -53,7 +53,7 @@ auto get_value_by_key(T const &object, const char *key) -> decltype(object.get_v int lua_error_callback(lua_State *L) // This is so I can use my own function as an // exception handler, pcall_log() { - luabind::object error_msg(luabind::from_stack(L, -1)); + std::string error_msg = lua_tostring(L, -1); std::ostringstream error_stream; error_stream << error_msg; throw osrm::exception("ERROR occured in profile script:\n" + error_stream.str());