Guest User

Untitled

a guest
Nov 19th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. proc throwPair(value: int) =
  2. if (value mod 2) != 0:
  3. echo "Passed for ", value
  4. else:
  5. raise newException(ArithmeticError, "Bad value")
  6.  
  7. template ignoreArithmetic(body: stmt): stmt {.immediate.} =
  8. try: body
  9. except ArithmeticError: discard
  10.  
  11. template ignoreArithmeticAndLog(body: stmt): stmt {.immediate.} =
  12. try: body
  13. except ArithmeticError:
  14. echo "Did ignore arithmetic error!"
  15.  
  16. proc tester() =
  17. for f in 0..10:
  18. ignoreArithmeticAndLog:
  19. throwPair f
  20.  
  21. tester()
Add Comment
Please, Sign In to add comment