Guard against null exception (#10162)

This commit is contained in:
rec
2019-01-04 15:05:03 +01:00
committed by Andreas Rumpf
parent 4eee92a7a3
commit ba7d33b4e4
2 changed files with 4 additions and 1 deletions

View File

@@ -46,7 +46,7 @@ proc nimCharToStr(x: char): string {.compilerproc.} =
result[0] = x
proc isNimException(): bool {.asmNoStackFrame.} =
asm "return `lastJSError`.m_type;"
asm "return `lastJSError` && `lastJSError`.m_type;"
proc getCurrentException*(): ref Exception {.compilerRtl, benign.} =
if isNimException(): result = cast[ref Exception](lastJSError)

View File

@@ -9,6 +9,9 @@ js 3.14
# This file tests the JavaScript generator
doAssert getCurrentException() == nil
doAssert getCurrentExceptionMsg() == ""
# #335
proc foo() =
var bar = "foo"