summary refs log tree commit diff stats
path: root/tests/exception/tunhandledexc.nim
blob: 6ca311d38febb100665d44df7051ba70d07413c8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
discard """
  cmd: "nim $target -d:release $options $file"
  outputsub: '''tunhandledexc.nim(15)    genErrors
Error: unhandled exception: bla [ESomeOtherErr]'''
  exitcode: "1"
"""
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")

when true:
  try: discard except: discard

  try:
    genErrors("errssor!")
  except ESomething:
    echo("Error happened")