-
-
Save rightfold/aad23c6c81abf247efd3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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