From 5d699607342bdc64fd084885224264b495e4bbd6 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 12 Sep 2000 10:49:05 -0300 Subject: [PATCH] error codes as strings for dofile and dostring --- lbaselib.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lbaselib.c b/lbaselib.c index 708ce4ff..df1f9bd2 100644 --- 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; } }