| 112 | |
| 113 | |
| 114 | l_noret luaD_throw (lua_State *L, int errcode) { |
| 115 | if (L->errorJmp) { /* thread has an error handler? */ |
| 116 | L->errorJmp->status = errcode; /* set status */ |
| 117 | LUAI_THROW(L, L->errorJmp); /* jump to it */ |
| 118 | } |
| 119 | else { /* thread has no error handler */ |
| 120 | global_State *g = G(L); |
| 121 | errcode = luaF_close(L, L->stack, errcode); /* close all upvalues */ |
| 122 | L->status = cast_byte(errcode); /* mark it as dead */ |
| 123 | if (g->mainthread->errorJmp) { /* main thread has a handler? */ |
| 124 | setobjs2s(L, g->mainthread->top++, L->top - 1); /* copy error obj. */ |
| 125 | luaD_throw(g->mainthread, errcode); /* re-throw in main thread */ |
| 126 | } |
| 127 | else { /* no handler at all; abort */ |
| 128 | if (g->panic) { /* panic function? */ |
| 129 | luaD_seterrorobj(L, errcode, L->top); /* assume EXTRA_STACK */ |
| 130 | if (L->ci->top < L->top) |
| 131 | L->ci->top = L->top; /* pushing msg. can break this invariant */ |
| 132 | lua_unlock(L); |
| 133 | g->panic(L); /* call panic function (last chance to jump out) */ |
| 134 | } |
| 135 | abort(); |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | |
| 141 | int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { |
no test coverage detected