commit 5d699607342bdc64fd084885224264b495e4bbd6
parent d1c351857d646c9b9726e47d1f861e1b2e064a59
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Tue, 12 Sep 2000 10:48:43 -0300
error codes as strings for dofile and dostring
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lbaselib.c b/lbaselib.c
@@ -1,5 +1,5 @@
/*
-** $Id: $
+** $Id: lbaselib.c,v 1.1 2000/09/05 19:33:56 roberto Exp roberto $
** Basic library
** See Copyright Notice in lua.h
*/
@@ -217,6 +217,8 @@ static int luaB_next (lua_State *L) {
static int passresults (lua_State *L, int status, int oldtop) {
+ static const char *const errornames[] =
+ {"OK", "RUN-TIME ERROR", "FILE ERROR", "SYNTAX ERROR", "MEMORY ERROR"};
if (status == 0) {
int nresults = lua_gettop(L) - oldtop;
if (nresults > 0)
@@ -228,7 +230,7 @@ static int passresults (lua_State *L, int status, int oldtop) {
}
else { /* error */
lua_pushnil(L);
- lua_pushnumber(L, status); /* error code */
+ lua_pushstring(L, errornames[status]); /* error code */
return 2;
}
}