Skip to content

Instantly share code, notes, and snippets.

@kdeme
Created April 20, 2020 16:27
Show Gist options
  • Save kdeme/ec2d78191ab205fb1f731bc598f8bc38 to your computer and use it in GitHub Desktop.
Save kdeme/ec2d78191ab205fb1f731bc598f8bc38 to your computer and use it in GitHub Desktop.
Forward declare invalid raises behaviour
type AnotherError = object of CatchableError
proc thisRaises() {.raises:[AnotherError].} # Works
#proc thisRaises() # Error: can raise an unlisted exception: Exception - at line 8 :(
proc anotherProc() {.raises:[AnotherError].} =
echo "Hoi"
thisRaises()
proc thisRaises() {.raises:[AnotherError].} = # Whatever is put here doesn't seem to matter, can even omit.
echo "Hi"
raise newException(AnotherError, "oh no")
anotherProc()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment