You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
stevedonovan edited this page Feb 18, 2013
·
7 revisions
Although people might think that a modern language needs try/catch, the usual Lua pcall idiom is not as clumsy in MoonScript, especially if we specialize it for the case where the function return value is not important.
For example,
try =(f)->
ok,err =pcall f
ifnot ok then err\gsub '^[^:]+:%d+: ',''
err = try ->print a.x
if err
print'error!',err
--~ error! attempt to index global 'a' (a nil value)