mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-07 13:33:22 +00:00
Guard against null exception (#10162)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -9,6 +9,9 @@ js 3.14
|
||||
|
||||
# This file tests the JavaScript generator
|
||||
|
||||
doAssert getCurrentException() == nil
|
||||
doAssert getCurrentExceptionMsg() == ""
|
||||
|
||||
# #335
|
||||
proc foo() =
|
||||
var bar = "foo"
|
||||
|
||||
Reference in New Issue
Block a user