Created
February 2, 2015 14:18
-
-
Save def-/b52fa7a01d9b021873bb to your computer and use it in GitHub Desktop.
ctrl-c exceptions
This file contains hidden or 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
import os | |
type CtrlCException = object of Exception | |
proc handler() {.noconv.} = | |
raise new CtrlCException | |
setControlCHook(handler) | |
try: | |
sleep(10000) | |
except CtrlCException: | |
echo "Caught the exception!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment