treraise.nim 408 B

123456789101112131415161718192021
  1. discard """
  2. outputsub: "Error: unhandled exception: bla [ESomeOtherErr]"
  3. exitcode: "1"
  4. """
  5. type
  6. ESomething = object of Exception
  7. ESomeOtherErr = object of Exception
  8. proc genErrors(s: string) =
  9. if s == "error!":
  10. raise newException(ESomething, "Test")
  11. else:
  12. raise newException(EsomeotherErr, "bla")
  13. try:
  14. genErrors("errssor!")
  15. except ESomething:
  16. echo("Error happened")
  17. except:
  18. raise