texceptionbreak.nim 613 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. discard """
  2. output: "1\n2\n3\n4"
  3. """
  4. # First variety
  5. try:
  6. raise newException(OSError, "Problem")
  7. except OSError:
  8. for y in [1, 2, 3]:
  9. discard
  10. try:
  11. discard
  12. except OSError:
  13. discard
  14. echo "1"
  15. # Second Variety
  16. try:
  17. raise newException(OSError, "Problem")
  18. except OSError:
  19. for y in [1, 2, 3]:
  20. discard
  21. for y in [1, 2, 3]:
  22. discard
  23. echo "2"
  24. # Third Variety
  25. try:
  26. raise newException(OSError, "Problem")
  27. except OSError:
  28. block label:
  29. break label
  30. echo "3"
  31. # Fourth Variety
  32. block label:
  33. try:
  34. raise newException(OSError, "Problem")
  35. except OSError:
  36. break label
  37. echo "4"