don't raise exception in the default handler (#9783)

fixes #9657
This commit is contained in:
alaviss
2018-11-22 20:46:07 +07:00
committed by Andreas Rumpf
parent 02351d02e7
commit c7eba64dee
3 changed files with 14 additions and 8 deletions

View File

@@ -17,13 +17,6 @@
const
NilLibHandle: LibHandle = nil
proc c_fwrite(buf: pointer, size, n: csize, f: File): cint {.
importc: "fwrite", header: "<stdio.h>".}
proc rawWrite(f: File, s: string|cstring) =
# we cannot throw an exception here!
discard c_fwrite(cstring(s), 1, s.len, f)
proc nimLoadLibraryError(path: string) =
# carefully written to avoid memory allocation:
stderr.rawWrite("could not load: ")

View File

@@ -17,8 +17,15 @@ var
## instead of stdmsg.write when printing stacktrace.
## Unstable API.
proc c_fwrite(buf: pointer, size, n: csize, f: File): cint {.
importc: "fwrite", header: "<stdio.h>".}
proc rawWrite(f: File, s: string|cstring) =
# we cannot throw an exception here!
discard c_fwrite(cstring(s), 1, s.len, f)
when not defined(windows) or not defined(guiapp):
proc writeToStdErr(msg: cstring) = write(stdmsg, msg)
proc writeToStdErr(msg: cstring) = rawWrite(stdmsg, msg)
else:
proc MessageBoxA(hWnd: cint, lpText, lpCaption: cstring, uType: int): int32 {.

View File

@@ -0,0 +1,6 @@
discard """
action: run
exitcode: 1
"""
close stdmsg
writeLine stdmsg, "exception!"