This commit is contained in:
Andreas Rumpf 2017-07-13 04:43:53 +02:00
commit 0c271f5420
3 changed files with 17 additions and 6 deletions

View file

@ -442,6 +442,7 @@ type
## providing an exception message ## providing an exception message
## is bad style. ## is bad style.
trace: string trace: string
up: ref Exception # used for stacking exceptions. Not exported!
SystemError* = object of Exception ## \ SystemError* = object of Exception ## \
## Abstract class for exceptions that the runtime system raises. ## Abstract class for exceptions that the runtime system raises.

View file

@ -73,12 +73,11 @@ proc popSafePoint {.compilerRtl, inl.} =
excHandler = excHandler.prev excHandler = excHandler.prev
proc pushCurrentException(e: ref Exception) {.compilerRtl, inl.} = proc pushCurrentException(e: ref Exception) {.compilerRtl, inl.} =
#if e.parent.isNil: e.up = currException
# e.parent = currException
currException = e currException = e
proc popCurrentException {.compilerRtl, inl.} = proc popCurrentException {.compilerRtl, inl.} =
currException = nil # currException.parent currException = currException.up
# some platforms have native support for stack traces: # some platforms have native support for stack traces:
const const

View file

@ -1,6 +1,11 @@
discard """ discard """
file: "tfinally3.nim" file: "tfinally3.nim"
output: "false" output: '''false
Within finally->try
Traceback (most recent call last)
tfinally3.nim(24) tfinally3
Error: unhandled exception: First [Exception]'''
exitCode: 1
""" """
# Test break in try statement: # Test break in try statement:
@ -14,5 +19,11 @@ proc main: bool =
echo main() #OUT false echo main() #OUT false
# bug #5871
try:
raise newException(Exception, "First")
finally:
try:
raise newException(Exception, "Within finally->try")
except:
echo getCurrentExceptionMsg()