diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-05-15 15:57:44 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-05-15 15:57:44 -0300 |
commit | b7a0503c1d72603b8f7e480f2abecbc05348cb69 (patch) | |
tree | bfac646fea320f73abec2ee57a0c96a704452884 /ldebug.c | |
parent | 1c328a191a8b86b7ad601cb9a935f1da5373fdf7 (diff) | |
download | lua-b7a0503c1d72603b8f7e480f2abecbc05348cb69.tar.gz lua-b7a0503c1d72603b8f7e480f2abecbc05348cb69.tar.bz2 lua-b7a0503c1d72603b8f7e480f2abecbc05348cb69.zip |
new format for error messages
Diffstat (limited to 'ldebug.c')
-rw-r--r-- | ldebug.c | 30 |
1 files changed, 23 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 1.114 2002/05/13 13:09:00 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 1.115 2002/05/14 17:52:22 roberto Exp roberto $ |
3 | ** Debug Interface | 3 | ** Debug Interface |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -144,11 +144,11 @@ static void funcinfo (lua_State *L, lua_Debug *ar, StkId func) { | |||
144 | if (ttype(func) == LUA_TFUNCTION) | 144 | if (ttype(func) == LUA_TFUNCTION) |
145 | cl = clvalue(func); | 145 | cl = clvalue(func); |
146 | else { | 146 | else { |
147 | luaD_runerror(L, "value for `lua_getinfo' is not a function"); | 147 | luaG_runerror(L, "value for `lua_getinfo' is not a function"); |
148 | cl = NULL; /* to avoid warnings */ | 148 | cl = NULL; /* to avoid warnings */ |
149 | } | 149 | } |
150 | if (cl->c.isC) { | 150 | if (cl->c.isC) { |
151 | ar->source = "=C"; | 151 | ar->source = "=[C]"; |
152 | ar->linedefined = -1; | 152 | ar->linedefined = -1; |
153 | ar->what = "C"; | 153 | ar->what = "C"; |
154 | } | 154 | } |
@@ -481,10 +481,10 @@ void luaG_typeerror (lua_State *L, const TObject *o, const char *op) { | |||
481 | if (isinstack(L->ci, o)) | 481 | if (isinstack(L->ci, o)) |
482 | kind = getobjname(L, L->ci, o - L->ci->base, &name); | 482 | kind = getobjname(L, L->ci, o - L->ci->base, &name); |
483 | if (kind) | 483 | if (kind) |
484 | luaO_verror(L, "attempt to %s %s `%s' (a %s value)", | 484 | luaG_runerror(L, "attempt to %s %s `%s' (a %s value)", |
485 | op, kind, name, t); | 485 | op, kind, name, t); |
486 | else | 486 | else |
487 | luaO_verror(L, "attempt to %s a %s value", op, t); | 487 | luaG_runerror(L, "attempt to %s a %s value", op, t); |
488 | } | 488 | } |
489 | 489 | ||
490 | 490 | ||
@@ -507,8 +507,24 @@ void luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2) { | |||
507 | const char *t1 = luaT_typenames[ttype(p1)]; | 507 | const char *t1 = luaT_typenames[ttype(p1)]; |
508 | const char *t2 = luaT_typenames[ttype(p2)]; | 508 | const char *t2 = luaT_typenames[ttype(p2)]; |
509 | if (t1[2] == t2[2]) | 509 | if (t1[2] == t2[2]) |
510 | luaO_verror(L, "attempt to compare two %s values", t1); | 510 | luaG_runerror(L, "attempt to compare two %s values", t1); |
511 | else | 511 | else |
512 | luaO_verror(L, "attempt to compare %s with %s", t1, t2); | 512 | luaG_runerror(L, "attempt to compare %s with %s", t1, t2); |
513 | } | ||
514 | |||
515 | |||
516 | void luaG_runerror (lua_State *L, const char *fmt, ...) { | ||
517 | const char *msg; | ||
518 | va_list argp; | ||
519 | va_start(argp, fmt); | ||
520 | msg = luaO_vpushstr(L, fmt, argp); | ||
521 | va_end(argp); | ||
522 | if (isLmark(L->ci)) { | ||
523 | char buff[LUA_IDSIZE]; | ||
524 | int line = currentline(L, L->ci); | ||
525 | luaO_chunkid(buff, getstr(getluaproto(L->ci)->source), LUA_IDSIZE); | ||
526 | msg = luaO_pushstr(L, "%s:%d: %s", buff, line, msg); | ||
527 | } | ||
528 | luaD_error(L, msg, LUA_ERRRUN); | ||
513 | } | 529 | } |
514 | 530 | ||