summary refs log blame commit diff stats
path: root/tests/exception/texcpt1.nim
blob: 50a95eeec82235c07508c334576ca6767957a39f (plain) (tree)
1
2
3
4
5
6



                 

                                     























                                            
discard """
  outputsub: "-6"
"""
type
  ESomething = object of Exception
  ESomeOtherErr = object of Exception

proc genErrors(s: string) =
  if s == "error!":
    raise newException(ESomething, "Test")
  else:
    raise newException(EsomeotherErr, "bla")

proc raiseBla(): int =
  try:
    genErrors("errssor!")
  except ESomething:
    echo("Error happened")
  except:
    raise

proc blah(): int =
  try:
    result = raiseBla()
  except ESomeOtherErr:
    result = -6

echo blah()