diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-09-12 10:49:05 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-09-12 10:49:05 -0300 |
commit | 5d699607342bdc64fd084885224264b495e4bbd6 (patch) | |
tree | 6766fcc011eef97b1c08ab2b1adf610a715c5aee | |
parent | d1c351857d646c9b9726e47d1f861e1b2e064a59 (diff) | |
download | lua-5d699607342bdc64fd084885224264b495e4bbd6.tar.gz lua-5d699607342bdc64fd084885224264b495e4bbd6.tar.bz2 lua-5d699607342bdc64fd084885224264b495e4bbd6.zip |
error codes as strings for dofile and dostring
-rw-r--r-- | lbaselib.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: $ | 2 | ** $Id: lbaselib.c,v 1.1 2000/09/05 19:33:56 roberto Exp roberto $ |
3 | ** Basic library | 3 | ** Basic library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -217,6 +217,8 @@ static int luaB_next (lua_State *L) { | |||
217 | 217 | ||
218 | 218 | ||
219 | static int passresults (lua_State *L, int status, int oldtop) { | 219 | static int passresults (lua_State *L, int status, int oldtop) { |
220 | static const char *const errornames[] = | ||
221 | {"OK", "RUN-TIME ERROR", "FILE ERROR", "SYNTAX ERROR", "MEMORY ERROR"}; | ||
220 | if (status == 0) { | 222 | if (status == 0) { |
221 | int nresults = lua_gettop(L) - oldtop; | 223 | int nresults = lua_gettop(L) - oldtop; |
222 | if (nresults > 0) | 224 | if (nresults > 0) |
@@ -228,7 +230,7 @@ static int passresults (lua_State *L, int status, int oldtop) { | |||
228 | } | 230 | } |
229 | else { /* error */ | 231 | else { /* error */ |
230 | lua_pushnil(L); | 232 | lua_pushnil(L); |
231 | lua_pushnumber(L, status); /* error code */ | 233 | lua_pushstring(L, errornames[status]); /* error code */ |
232 | return 2; | 234 | return 2; |
233 | } | 235 | } |
234 | } | 236 | } |