* Fixes #9434
This commit is contained in:
parent
f670c55daa
commit
dfb8730f51
4 changed files with 16 additions and 5 deletions
|
|
@ -608,8 +608,10 @@ proc genRaiseStmt(p: BProc, t: PNode) =
|
||||||
if isImportedException(typ, p.config):
|
if isImportedException(typ, p.config):
|
||||||
lineF(p, cpsStmts, "throw $1;$n", [e])
|
lineF(p, cpsStmts, "throw $1;$n", [e])
|
||||||
else:
|
else:
|
||||||
lineCg(p, cpsStmts, "#raiseException((#Exception*)$1, $2);$n",
|
lineCg(p, cpsStmts, "#raiseExceptionEx((#Exception*)$1, $2, $3, $4, $5);$n",
|
||||||
[e, makeCString(typ.sym.name.s)])
|
[e, makeCString(typ.sym.name.s),
|
||||||
|
makeCString(if p.prc != nil: p.prc.name.s else: p.module.module.name.s),
|
||||||
|
makeCString(toFileName(p.config, t.info)), rope(toLinenumber(t.info))])
|
||||||
else:
|
else:
|
||||||
genLineDir(p, t)
|
genLineDir(p, t)
|
||||||
# reraise the last exception:
|
# reraise the last exception:
|
||||||
|
|
|
||||||
|
|
@ -381,6 +381,8 @@ proc raiseExceptionAux(e: ref Exception) =
|
||||||
xadd(buf, s, s.len)
|
xadd(buf, s, s.len)
|
||||||
var buf: array[0..2000, char]
|
var buf: array[0..2000, char]
|
||||||
var L = 0
|
var L = 0
|
||||||
|
if e.trace.len != 0:
|
||||||
|
add(buf, $e.trace) # gc allocation
|
||||||
add(buf, "Error: unhandled exception: ")
|
add(buf, "Error: unhandled exception: ")
|
||||||
add(buf, e.msg)
|
add(buf, e.msg)
|
||||||
add(buf, " [")
|
add(buf, " [")
|
||||||
|
|
@ -394,7 +396,7 @@ proc raiseExceptionAux(e: ref Exception) =
|
||||||
showErrorMessage(tbuf())
|
showErrorMessage(tbuf())
|
||||||
quitOrDebug()
|
quitOrDebug()
|
||||||
|
|
||||||
proc raiseException(e: ref Exception, ename: cstring) {.compilerRtl.} =
|
proc raiseExceptionEx(e: ref Exception, ename, procname, filename: cstring, line: int) {.compilerRtl.} =
|
||||||
if e.name.isNil: e.name = ename
|
if e.name.isNil: e.name = ename
|
||||||
when hasSomeStackTrace:
|
when hasSomeStackTrace:
|
||||||
if e.trace.len == 0:
|
if e.trace.len == 0:
|
||||||
|
|
@ -403,8 +405,14 @@ proc raiseException(e: ref Exception, ename: cstring) {.compilerRtl.} =
|
||||||
e.trace.add reraisedFrom(reraisedFromBegin)
|
e.trace.add reraisedFrom(reraisedFromBegin)
|
||||||
auxWriteStackTrace(framePtr, e.trace)
|
auxWriteStackTrace(framePtr, e.trace)
|
||||||
e.trace.add reraisedFrom(reraisedFromEnd)
|
e.trace.add reraisedFrom(reraisedFromEnd)
|
||||||
|
else:
|
||||||
|
if procname != nil and filename != nil:
|
||||||
|
e.trace.add StackTraceEntry(procname: procname, filename: filename, line: line)
|
||||||
raiseExceptionAux(e)
|
raiseExceptionAux(e)
|
||||||
|
|
||||||
|
proc raiseException(e: ref Exception, ename: cstring) {.compilerRtl.} =
|
||||||
|
raiseExceptionEx(e, ename, nil, nil, 0)
|
||||||
|
|
||||||
proc reraiseException() {.compilerRtl.} =
|
proc reraiseException() {.compilerRtl.} =
|
||||||
if currException == nil:
|
if currException == nil:
|
||||||
sysFatal(ReraiseError, "no exception to reraise")
|
sysFatal(ReraiseError, "no exception to reraise")
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,6 @@ proc jsTests(r: var TResults, cat: Category, options: string) =
|
||||||
for testfile in ["exception/texceptions", "exception/texcpt1",
|
for testfile in ["exception/texceptions", "exception/texcpt1",
|
||||||
"exception/texcsub", "exception/tfinally",
|
"exception/texcsub", "exception/tfinally",
|
||||||
"exception/tfinally2", "exception/tfinally3",
|
"exception/tfinally2", "exception/tfinally3",
|
||||||
"exception/tunhandledexc",
|
|
||||||
"actiontable/tactiontable", "method/tmultimjs",
|
"actiontable/tactiontable", "method/tmultimjs",
|
||||||
"varres/tvarres0", "varres/tvarres3", "varres/tvarres4",
|
"varres/tvarres0", "varres/tvarres3", "varres/tvarres4",
|
||||||
"varres/tvartup", "misc/tints", "misc/tunsignedinc",
|
"varres/tvartup", "misc/tints", "misc/tunsignedinc",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
discard """
|
discard """
|
||||||
file: "tunhandledexc.nim"
|
file: "tunhandledexc.nim"
|
||||||
outputsub: "Error: unhandled exception: bla [ESomeOtherErr]"
|
cmd: "nim $target -d:release $options $file"
|
||||||
|
outputsub: '''tunhandledexc.nim(16) genErrors
|
||||||
|
Error: unhandled exception: bla [ESomeOtherErr]'''
|
||||||
exitcode: "1"
|
exitcode: "1"
|
||||||
"""
|
"""
|
||||||
type
|
type
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue