alibaba / wax

Wax is a framework that lets you write native iPhone apps in Lua.
http://github.com/probablycorey/wax
MIT License
1.84k stars 280 forks source link

How to implement @try in LUA? #28

Closed lovecactus closed 8 years ago

lovecactus commented 8 years ago

Is this possible in wax? Thanks!

intheway commented 8 years ago
local unsafeFun = function()
        --put your code here which may cause exception 
        self:testThrowException({1,2});
    end

    local ret, msg = pcall(unsafeFun);
    if ret == false then
        --exception happened
    end
    print("ret=" .. tostring(ret) .." msg=" .. tostring(msg))