MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / db_errorfb

Function db_errorfb

Source/Misc/lua/src/lua.c:11838–11888  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11836#define LEVELS2 10 /* size of the second part of the stack */
11837
11838static int db_errorfb (lua_State *L) {
11839int level;
11840int firstpart = 1; /* still before eventual `...' */
11841int arg;
11842lua_State *L1 = getthread(L, &arg);
11843lua_Debug ar;
11844if (lua_isnumber(L, arg+2)) {
11845level = (int)lua_tointeger(L, arg+2);
11846lua_pop(L, 1);
11847}
11848else
11849level = (L == L1) ? 1 : 0; /* level 0 may be this own function */
11850if (lua_gettop(L) == arg)
11851lua_pushliteral(L, "");
11852else if (!lua_isstring(L, arg+1)) return 1; /* message is not a string */
11853else lua_pushliteral(L, "\n");
11854lua_pushliteral(L, "stack traceback:");
11855while (lua_getstack(L1, level++, &ar)) {
11856if (level > LEVELS1 && firstpart) {
11857/* no more than `LEVELS2' more levels? */
11858if (!lua_getstack(L1, level+LEVELS2, &ar))
11859level--; /* keep going */
11860else {
11861lua_pushliteral(L, "\n\t..."); /* too many levels */
11862while (lua_getstack(L1, level+LEVELS2, &ar)) /* find last levels */
11863level++;
11864}
11865firstpart = 0;
11866continue;
11867}
11868lua_pushliteral(L, "\n\t");
11869lua_getinfo(L1, "Snl", &ar);
11870lua_pushfstring(L, "%s:", ar.short_src);
11871if (ar.currentline > 0)
11872lua_pushfstring(L, "%d:", ar.currentline);
11873if (*ar.namewhat != '\0') /* is there a name? */
11874lua_pushfstring(L, " in function " LUA_QS, ar.name);
11875else {
11876if (*ar.what == 'm') /* main? */
11877lua_pushfstring(L, " in main chunk");
11878else if (*ar.what == 'C' || *ar.what == 't')
11879lua_pushliteral(L, " ?"); /* C function or tail call */
11880else
11881lua_pushfstring(L, " in function <%s:%d>",
11882ar.short_src, ar.linedefined);
11883}
11884lua_concat(L, lua_gettop(L) - arg);
11885}
11886lua_concat(L, lua_gettop(L) - arg);
11887return 1;
11888}
11889
11890
11891static const luaL_Reg dblib[] = {

Callers

nothing calls this directly

Calls 9

getthreadFunction · 0.85
lua_isnumberFunction · 0.85
lua_tointegerFunction · 0.85
lua_gettopFunction · 0.85
lua_isstringFunction · 0.85
lua_getstackFunction · 0.85
lua_getinfoFunction · 0.85
lua_pushfstringFunction · 0.85
lua_concatFunction · 0.85

Tested by

no test coverage detected