local err = ...; local i = 2; io.stderr:write("unhandled error: ", tostring(err), "\n"); while true do local info = debug.getinfo(i, "Snl"); if info == nil then break end local name = info.name; local location = info.short_src; if location == "[C]" then location = "at "; elseif location:find "%[string" then location = "at "; else location = "at " .. location; end if info.currentline > 0 then location = location .. ":" .. info.currentline; end if name ~= nil then io.stderr:write(" ", location, " in ", name, "\n"); else io.stderr:write(" ", location, "\n"); end i = i + 1; end return err;