Skip to content

Instantly share code, notes, and snippets.

@def-
Created February 2, 2015 14:18
Show Gist options
  • Save def-/b52fa7a01d9b021873bb to your computer and use it in GitHub Desktop.
Save def-/b52fa7a01d9b021873bb to your computer and use it in GitHub Desktop.
ctrl-c exceptions
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