error codes as strings for dofile and dostring
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: $
|
** $Id: lbaselib.c,v 1.1 2000/09/05 19:33:56 roberto Exp roberto $
|
||||||
** Basic library
|
** Basic library
|
||||||
** See Copyright Notice in lua.h
|
** 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 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) {
|
if (status == 0) {
|
||||||
int nresults = lua_gettop(L) - oldtop;
|
int nresults = lua_gettop(L) - oldtop;
|
||||||
if (nresults > 0)
|
if (nresults > 0)
|
||||||
@@ -228,7 +230,7 @@ static int passresults (lua_State *L, int status, int oldtop) {
|
|||||||
}
|
}
|
||||||
else { /* error */
|
else { /* error */
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
lua_pushnumber(L, status); /* error code */
|
lua_pushstring(L, errornames[status]); /* error code */
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user