lua-users home
lua-l archive

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


Er, I meant they don't provide a stack trace or anything.


Well, kind of. If your error handler honors __tostring metamethod ...

errtablemt = {
    __tostring = function(t)
        return string.format(
            'An error ocurred with error code %d: %s.\n%s',
            t.code,
            t.msg,
            debug.traceback()
        )
    end
}

function raise(errtable)
    error(setmetatable(errtable, errtablemt))
end

---

function disfunctional()
    raise{code=123, msg='bla bla bla'}
end

print(pcall(disfunctional))


I don't know if this is what you meant, though.

--rb