Skip to content

Instantly share code, notes, and snippets.

@monolithed
Forked from cwarden/example-try-catch.lua
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monolithed/c247bf42086543d93209 to your computer and use it in GitHub Desktop.
Save monolithed/c247bf42086543d93209 to your computer and use it in GitHub Desktop.
require "try-catch"
try {
function()
error('oops')
end,
catch {
function(error)
print('caught error: ' .. error)
end
}
}
function catch(what)
return what[1]
end
function try(what)
status, result = pcall(what[1])
if not status then
what[2](result)
end
return result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment