| 123 | |
| 124 | |
| 125 | l_noret luaD_throw (lua_State *L, TStatus errcode) { |
| 126 | if (L->errorJmp) { /* thread has an error handler? */ |
| 127 | L->errorJmp->status = errcode; /* set status */ |
| 128 | LUAI_THROW(L, L->errorJmp); /* jump to it */ |
| 129 | } |
| 130 | else { /* thread has no error handler */ |
| 131 | global_State *g = G(L); |
| 132 | lua_State *mainth = mainthread(g); |
| 133 | errcode = luaE_resetthread(L, errcode); /* close all upvalues */ |
| 134 | L->status = errcode; |
| 135 | if (mainth->errorJmp) { /* main thread has a handler? */ |
| 136 | setobjs2s(L, mainth->top.p++, L->top.p - 1); /* copy error obj. */ |
| 137 | luaD_throw(mainth, errcode); /* re-throw in main thread */ |
| 138 | } |
| 139 | else { /* no handler at all; abort */ |
| 140 | if (g->panic) { /* panic function? */ |
| 141 | lua_unlock(L); |
| 142 | g->panic(L); /* call panic function (last chance to jump out) */ |
| 143 | } |
| 144 | abort(); |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | |
| 150 | l_noret luaD_throwbaselevel (lua_State *L, TStatus errcode) { |
no test coverage detected