MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / handle_lua_error

Function handle_lua_error

src/extractor/scripting_environment_lua.cpp:96–110  ·  view source on GitHub ↗

Handle a lua error thrown in a protected function by printing the traceback and bubbling exception up to caller. Lua errors are generally unrecoverable, so this exception should not be caught but instead should terminate the process. The point of having this error handler rather than just using unprotected Lua functions which terminate the process automatically is that this function provides more

Source from the content-addressed store, hash-verified

94// than just using unprotected Lua functions which terminate the process automatically is that this
95// function provides more useful error messages including Lua tracebacks and line numbers.
96void handle_lua_error(const sol::protected_function_result &luares)
97{
98 sol::error luaerr = luares;
99 const auto msg = luaerr.what();
100 if (msg != nullptr)
101 {
102 // util::Log is thread-safe
103 util::UnbufferedLog(logERROR) << msg << "\n";
104 }
105 else
106 {
107 util::UnbufferedLog(logERROR) << "unknown error\n";
108 }
109 throw util::exception("Lua error (see stderr for traceback)");
110}
111
112Sol2ScriptingEnvironment::Sol2ScriptingEnvironment(
113 const std::string &file_name,

Callers 5

InitContextMethod · 0.85
ProcessTurnMethod · 0.85
ProcessSegmentMethod · 0.85
ProcessNodeMethod · 0.85
ProcessWayMethod · 0.85

Calls 3

UnbufferedLogClass · 0.85
exceptionClass · 0.85
whatMethod · 0.80

Tested by

no test coverage detected