This commit is contained in:
Andrii Riabushenko 2019-04-30 21:46:45 +01:00
commit 7cfc7cfb26
2 changed files with 33 additions and 6 deletions

View file

@ -342,6 +342,9 @@ proc raiseExceptionAux(e: ref Exception) =
if globalRaiseHook != nil: if globalRaiseHook != nil:
if not globalRaiseHook(e): return if not globalRaiseHook(e): return
when defined(cpp) and not defined(noCppExceptions): when defined(cpp) and not defined(noCppExceptions):
if e == currException:
{.emit: "throw;".}
else:
pushCurrentException(e) pushCurrentException(e)
raiseCounter.inc raiseCounter.inc
if raiseCounter == 0: if raiseCounter == 0:

View file

@ -5,6 +5,9 @@ bar
Need odd and >= 3 digits## Need odd and >= 3 digits##
baz baz
caught caught
--------
Triggered raises2
Raising ValueError
''' '''
""" """
@ -45,3 +48,24 @@ try:
finally: finally:
for foobar in strs: for foobar in strs:
discard discard
# issue #11118
echo "--------"
proc raises() =
raise newException(ValueError, "Raising ValueError")
proc raises2() =
try:
raises()
except ValueError as e:
echo "Triggered raises2"
raise e
try:
raises2()
except:
echo getCurrentExceptionMsg()
discard
doAssert: getCurrentException() == nil