Guard against null exception (#10162)
This commit is contained in:
parent
4eee92a7a3
commit
ba7d33b4e4
2 changed files with 4 additions and 1 deletions
|
|
@ -46,7 +46,7 @@ proc nimCharToStr(x: char): string {.compilerproc.} =
|
||||||
result[0] = x
|
result[0] = x
|
||||||
|
|
||||||
proc isNimException(): bool {.asmNoStackFrame.} =
|
proc isNimException(): bool {.asmNoStackFrame.} =
|
||||||
asm "return `lastJSError`.m_type;"
|
asm "return `lastJSError` && `lastJSError`.m_type;"
|
||||||
|
|
||||||
proc getCurrentException*(): ref Exception {.compilerRtl, benign.} =
|
proc getCurrentException*(): ref Exception {.compilerRtl, benign.} =
|
||||||
if isNimException(): result = cast[ref Exception](lastJSError)
|
if isNimException(): result = cast[ref Exception](lastJSError)
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,9 @@ js 3.14
|
||||||
|
|
||||||
# This file tests the JavaScript generator
|
# This file tests the JavaScript generator
|
||||||
|
|
||||||
|
doAssert getCurrentException() == nil
|
||||||
|
doAssert getCurrentExceptionMsg() == ""
|
||||||
|
|
||||||
# #335
|
# #335
|
||||||
proc foo() =
|
proc foo() =
|
||||||
var bar = "foo"
|
var bar = "foo"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue