mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-12 21:10:37 +00:00
Fix CLI abort when non lua string passed to error (#114)
This commit is contained in:
parent
733ae0498d
commit
e3f8c25e9e
1 changed files with 22 additions and 2 deletions
24
CLI/Repl.cpp
24
CLI/Repl.cpp
|
@ -169,7 +169,17 @@ static std::string runCode(lua_State* L, const std::string& source)
|
|||
}
|
||||
else
|
||||
{
|
||||
std::string error = (status == LUA_YIELD) ? "thread yielded unexpectedly" : lua_tostring(T, -1);
|
||||
std::string error;
|
||||
|
||||
if (status == LUA_YIELD)
|
||||
{
|
||||
error = "thread yielded unexpectedly";
|
||||
}
|
||||
else if (const char* str = lua_tostring(L, -1))
|
||||
{
|
||||
error = str;
|
||||
}
|
||||
|
||||
error += "\nstack backtrace:\n";
|
||||
error += lua_debugtrace(T);
|
||||
|
||||
|
@ -322,7 +332,17 @@ static bool runFile(const char* name, lua_State* GL)
|
|||
}
|
||||
else
|
||||
{
|
||||
std::string error = (status == LUA_YIELD) ? "thread yielded unexpectedly" : lua_tostring(L, -1);
|
||||
std::string error;
|
||||
|
||||
if (status == LUA_YIELD)
|
||||
{
|
||||
error = "thread yielded unexpectedly";
|
||||
}
|
||||
else if (const char* str = lua_tostring(L, -1))
|
||||
{
|
||||
error = str;
|
||||
}
|
||||
|
||||
error += "\nstacktrace:\n";
|
||||
error += lua_debugtrace(L);
|
||||
|
||||
|
|
Loading…
Reference in a new issue