Skip to content

Instantly share code, notes, and snippets.

@rightfold
Created January 20, 2014 14:34
Show Gist options
  • Save rightfold/aad23c6c81abf247efd3 to your computer and use it in GitHub Desktop.
Save rightfold/aad23c6c81abf247efd3 to your computer and use it in GitHub Desktop.
styx = {}
styx.lang = {}
styx.lang.try_catch = function(body, catch)
success, result = pcall(body)
if success then
return result
else
return catch(result.exception)
end
end
styx.lang.try_finally = function(body, finally)
success, result = pcall(body)
finally()
if success then
return result
else
error(result)
end
end
styx.lang.throw = function(exception)
error({ exception=exception })
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment