summary refs log blame commit diff stats
path: root/tests/exception/texcpt1.nim
blob: ec74c947016cc3181e8a506e1ee3802e9158afce (plain) (tree)





























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

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()