aboutsummaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-03-03 15:51:24 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-03-03 15:51:24 -0300
commit910310d3baa5475f8e571509a464c9e52fed91dd (patch)
treeb98d05194535a48dd1b1f8d3cee623f205e3b4ee /ldo.c
parentfacfcd497f1ac61fcd66ff7736c08ad03c527f18 (diff)
downloadlua-910310d3baa5475f8e571509a464c9e52fed91dd.tar.gz
lua-910310d3baa5475f8e571509a464c9e52fed91dd.tar.bz2
lua-910310d3baa5475f8e571509a464c9e52fed91dd.zip
if thread has no error handling, try main thread handler before panicking
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/ldo.c b/ldo.c
index e431e130..15764948 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 2.51 2008/11/06 12:43:51 roberto Exp roberto $ 2** $Id: ldo.c,v 2.52 2009/02/18 14:52:03 roberto Exp roberto $
3** Stack and Call structure of Lua 3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -83,13 +83,19 @@ void luaD_throw (lua_State *L, int errcode) {
83 L->errorJmp->status = errcode; 83 L->errorJmp->status = errcode;
84 LUAI_THROW(L, L->errorJmp); 84 LUAI_THROW(L, L->errorJmp);
85 } 85 }
86 else { 86 else { /* thread has no error handler */
87 L->status = cast_byte(errcode); 87 L->status = cast_byte(errcode); /* mark it as dead */
88 if (G(L)->panic) { 88 if (G(L)->mainthread->errorJmp) { /* main thread has a handler? */
89 lua_unlock(L); 89 setobjs2s(L, G(L)->mainthread->top++, L->top - 1); /* copy error obj. */
90 G(L)->panic(L); 90 luaD_throw(G(L)->mainthread, errcode); /* jump to it */
91 }
92 else {
93 if (G(L)->panic) {
94 lua_unlock(L);
95 G(L)->panic(L);
96 }
97 exit(EXIT_FAILURE);
91 } 98 }
92 exit(EXIT_FAILURE);
93 } 99 }
94} 100}
95 101