eris: remove file+line from most error messages

This commit is contained in:
2021-03-18 12:36:55 -04:00
parent fa23ad87c7
commit 05052f846e
5 changed files with 11 additions and 4 deletions

View File

@@ -192,11 +192,14 @@ LUALIB_API void luaL_where (lua_State *L, int level) {
lua_pushliteral(L, ""); /* else, no information available... */
}
LUALIB_API void luaL_no_where (lua_State *L, int level) {
lua_pushliteral(L, ""); /* else, no information available... */
}
LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) {
va_list argp;
va_start(argp, fmt);
luaL_where(L, 1);
luaL_no_where(L, 1);
lua_pushvfstring(L, fmt, argp);
va_end(argp);
lua_concat(L, 2);

View File

@@ -57,6 +57,7 @@ LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname);
LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname);
LUALIB_API void (luaL_where) (lua_State *L, int lvl);
LUALIB_API void (luaL_no_where) (lua_State *L, int lvl);
LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def,

View File

@@ -90,7 +90,7 @@ static int luaB_error (lua_State *L) {
int level = luaL_optint(L, 2, 1);
lua_settop(L, 1);
if (lua_isstring(L, 1) && level > 0) { /* add extra information? */
luaL_where(L, level);
luaL_no_where(L, level);
lua_pushvalue(L, 1);
lua_concat(L, 2);
}

View File

@@ -69,7 +69,7 @@ static int luaB_auxwrap (lua_State *L) {
int r = auxresume(L, co, lua_gettop(L));
if (r < 0) {
if (lua_isstring(L, -1)) { /* error object is a string? */
luaL_where(L, 1); /* add extra info */
luaL_no_where(L, 1); /* add extra info */
lua_insert(L, -2);
lua_concat(L, 2);
}

View File

@@ -586,6 +586,9 @@ static void addinfo (lua_State *L, const char *msg) {
}
}
static void no_addinfo (lua_State *L, const char *msg) {
// do nothing.
}
l_noret luaG_errormsg (lua_State *L) {
if (L->errfunc != 0) { /* is there an error handling function? */
@@ -603,7 +606,7 @@ l_noret luaG_errormsg (lua_State *L) {
l_noret luaG_runerror (lua_State *L, const char *fmt, ...) {
va_list argp;
va_start(argp, fmt);
addinfo(L, luaO_pushvfstring(L, fmt, argp));
no_addinfo(L, luaO_pushvfstring(L, fmt, argp));
va_end(argp);
luaG_errormsg(L);
}