tunhandledexc.nim 529 B

123456789101112131415161718192021222324
  1. discard """
  2. cmd: "nim $target -d:release $options $file"
  3. outputsub: '''tunhandledexc.nim(15) genErrors
  4. Error: unhandled exception: bla [ESomeOtherErr]'''
  5. exitcode: "1"
  6. """
  7. type
  8. ESomething = object of Exception
  9. ESomeOtherErr = object of Exception
  10. proc genErrors(s: string) =
  11. if s == "error!":
  12. raise newException(ESomething, "Test")
  13. else:
  14. raise newException(EsomeotherErr, "bla")
  15. when true:
  16. try: discard except: discard
  17. try:
  18. genErrors("errssor!")
  19. except ESomething:
  20. echo("Error happened")