t21972.nim 560 B

123456789101112131415161718192021222324252627282930313233
  1. discard """
  2. targets: "c cpp"
  3. outputsub: "Error: unhandled exception: Err2 [IOError]"
  4. exitcode: "1"
  5. """
  6. proc bar(x: var int) =
  7. inc x
  8. if x == 3:
  9. raise newException(ValueError, "H0")
  10. elif x == 5:
  11. raise newException(IOError, "H1")
  12. elif x > 7:
  13. raise newException(IOError, "H2")
  14. proc foo() =
  15. var i = 0
  16. while true:
  17. try:
  18. bar(i)
  19. echo i
  20. except ValueError:
  21. debugEcho("ValueError")
  22. except IOError:
  23. raise newException(IOError, "Err2")
  24. when isMainModule:
  25. foo()