lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Am 23.11.2014 um 15:58 schröbte Thiago L.:
Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
 > xpcall(function() error("Hi!", 0) end, function(h) print(h)
print(debug.traceback()) end)
Hi!
stack traceback:
     stdin:1: in function <stdin:1>
     [C]: in function 'error'
     stdin:1: in function <stdin:1>
     [C]: in function 'xpcall'
     stdin:1: in main chunk
     [C]: in ?

Why's it giving me a stacktrace?

Because you called `debug.traceback`.

I thought error(msg, 0) would hide them?

No. According to the Lua manual `error(msg, 0)` only leaves out the extra information about the error location (more specifically file name and line number) normally prepended to the error message. See [1] and [2].

Philipp

  [1]: http://www.lua.org/manual/5.2/manual.html#pdf-error
  [2]: http://www.lua.org/manual/5.2/manual.html#luaL_where