diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-09-25 11:20:37 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-09-25 11:20:37 -0300 |
| commit | 8ede2c353cddc8024f75802bb2ab714e334f1f8e (patch) | |
| tree | c870e0d4b6a3f4fdee3136eac6e9b7c8462525da /lua.c | |
| parent | 6384475ec4112361b0ab27de553e85863464b846 (diff) | |
| download | lua-github-8ede2c353cddc8024f75802bb2ab714e334f1f8e.tar.gz | |
detail in 'report' + message handler always is called with an
argument + 'report' already handles non-string error messages
Diffstat (limited to 'lua.c')
| -rw-r--r-- | lua.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -1,5 +1,5 @@ /* -** $Id: lua.c,v 1.212 2014/06/26 17:08:52 roberto Exp roberto $ +** $Id: lua.c,v 1.213 2014/06/30 19:48:08 roberto Exp roberto $ ** Lua stand-alone interpreter ** See Copyright Notice in lua.h */ @@ -164,9 +164,9 @@ static void l_message (const char *pname, const char *msg) { */ static int report (lua_State *L, int status) { if (status != LUA_OK) { - const char *msg = (lua_type(L, -1) == LUA_TSTRING) ? lua_tostring(L, -1) - : NULL; - if (msg == NULL) msg = "(error object is not a string)"; + const char *msg = (lua_type(L, -1) == LUA_TSTRING) + ? lua_tostring(L, -1) + : "(error object is not a string)"; l_message(progname, msg); lua_pop(L, 1); } @@ -181,10 +181,9 @@ static int msghandler (lua_State *L) { const char *msg = lua_tostring(L, 1); if (msg) /* is error object a string? */ luaL_traceback(L, L, msg, 1); /* use standard traceback */ - else if (!lua_isnoneornil(L, 1)) { /* non-string error object? */ - if (!luaL_callmeta(L, 1, "__tostring")) /* try its 'tostring' metamethod */ - lua_pushliteral(L, "(no error message)"); - } /* else no error object, does nothing */ + else /* non-string error object */ + luaL_callmeta(L, 1, "__tostring"); /* try its 'tostring' metamethod */ + /* if no metamethod, original object still is in the stack */ return 1; } |
