parent
9c7374abcd
commit
c9f184401c
2 changed files with 15 additions and 0 deletions
|
|
@ -4117,3 +4117,17 @@ template doAssertRaises*(exception, code: untyped): typed =
|
||||||
raiseAssert(astToStr(exception) &
|
raiseAssert(astToStr(exception) &
|
||||||
" wasn't raised, another error was raised instead by:\n"&
|
" wasn't raised, another error was raised instead by:\n"&
|
||||||
astToStr(code))
|
astToStr(code))
|
||||||
|
|
||||||
|
when defined(cpp) and appType != "lib" and not defined(js) and
|
||||||
|
not defined(nimscript) and hostOS != "standalone":
|
||||||
|
proc setTerminate(handler: proc() {.noconv.})
|
||||||
|
{.importc: "std::set_terminate", header: "<exception>".}
|
||||||
|
setTerminate proc() {.noconv.} =
|
||||||
|
# Remove ourself as a handler, reinstalling the default handler.
|
||||||
|
setTerminate(nil)
|
||||||
|
|
||||||
|
let ex = getCurrentException()
|
||||||
|
let trace = ex.getStackTrace()
|
||||||
|
stderr.write trace & "Error: unhandled exception: " & ex.msg &
|
||||||
|
" [" & $ex.name & "]\n"
|
||||||
|
quit 1
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ discard """
|
||||||
file: "tunhandledexc.nim"
|
file: "tunhandledexc.nim"
|
||||||
outputsub: "Error: unhandled exception: bla [ESomeOtherErr]"
|
outputsub: "Error: unhandled exception: bla [ESomeOtherErr]"
|
||||||
exitcode: "1"
|
exitcode: "1"
|
||||||
|
targets: "c cpp"
|
||||||
"""
|
"""
|
||||||
type
|
type
|
||||||
ESomething = object of Exception
|
ESomething = object of Exception
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue