Skip to content

Instantly share code, notes, and snippets.

@jrfondren
Created May 17, 2019 19:59
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 jrfondren/bf270df37e75bd49333da02058892d43 to your computer and use it in GitHub Desktop.
Save jrfondren/bf270df37e75bd49333da02058892d43 to your computer and use it in GitHub Desktop.
proc example =
defer: echo "deferred"
raise newException(ValueError, "an exception")
example()
proc example =
defer: echo "deferred"
try:
raise newException(ValueError, "an exception")
except ValueError:
echo "caught exception: " & getCurrentExceptionMsg()
example()
# ./deferex
deferred
deferex.nim(5) deferex
deferex.nim(3) example
Error: unhandled exception: an exception [ValueError]
# ./deferex2
caught exception: an exception
deferred
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment