Created
May 17, 2019 19:59
-
-
Save jrfondren/bf270df37e75bd49333da02058892d43 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
proc example = | |
defer: echo "deferred" | |
raise newException(ValueError, "an exception") | |
example() |
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
proc example = | |
defer: echo "deferred" | |
try: | |
raise newException(ValueError, "an exception") | |
except ValueError: | |
echo "caught exception: " & getCurrentExceptionMsg() | |
example() |
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
# ./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