move initialization of Lua error callback into scripting environment
This commit is contained in:
parent
f3e3eda69e
commit
288c241fb4
@ -65,19 +65,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
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::ostringstream error_stream;
|
||||
error_stream << error_msg;
|
||||
throw OSRMException("ERROR occured in profile script:\n" + error_stream.str());
|
||||
}
|
||||
}
|
||||
|
||||
int Extractor::Run(int argc, char *argv[])
|
||||
{
|
||||
ExtractorConfig extractor_config;
|
||||
@ -178,9 +165,6 @@ int Extractor::Run(int argc, char *argv[])
|
||||
timestamp_out.write(timestamp.c_str(), timestamp.length());
|
||||
timestamp_out.close();
|
||||
|
||||
// lua_State *lua_state = scripting_environment.getLuaState();
|
||||
luabind::set_pcall_callback(&lua_error_callback);
|
||||
|
||||
// initialize vectors holding parsed objects
|
||||
tbb::concurrent_vector<std::pair<std::size_t, ExtractionNode>> resulting_nodes;
|
||||
tbb::concurrent_vector<std::pair<std::size_t, ExtractionWay>> resulting_ways;
|
||||
|
@ -48,7 +48,17 @@ auto get_value_by_key(T const& object, const char *key) -> decltype(object.get_v
|
||||
{
|
||||
return object.get_value_by_key(key, "");
|
||||
}
|
||||
|
||||
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::ostringstream error_stream;
|
||||
error_stream << error_msg;
|
||||
throw OSRMException("ERROR occured in profile script:\n" + error_stream.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ScriptingEnvironment::ScriptingEnvironment(const char *file_name)
|
||||
: file_name(file_name)
|
||||
@ -129,6 +139,7 @@ lua_State *ScriptingEnvironment::getLuaState()
|
||||
ref = state;
|
||||
initLuaState(ref.get());
|
||||
}
|
||||
luabind::set_pcall_callback(&lua_error_callback);
|
||||
|
||||
return ref.get();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user