summary refs log tree commit diff stats
path: root/lib/system
diff options
context:
space:
mode:
authoryglukhov <yuriy.glukhov@gmail.com>2015-06-13 18:49:29 +0300
committeryglukhov <yuriy.glukhov@gmail.com>2015-06-15 21:49:49 +0300
commit090fc336416b9f7f9ee54dd8991bf1760d81df50 (patch)
tree731144095c789735a8d4c2c9e9225c32319cdc15 /lib/system
parent0272da01881dc81f3095d0dfeda2ff78f04e2618 (diff)
downloadNim-090fc336416b9f7f9ee54dd8991bf1760d81df50.tar.gz
Fixed and slightly changed exception handling.
Diffstat (limited to 'lib/system')
-rw-r--r--lib/system/jssys.nim29
1 files changed, 4 insertions, 25 deletions
diff --git a/lib/system/jssys.nim b/lib/system/jssys.nim
index f082023ee..a6711a778 100644
--- a/lib/system/jssys.nim
+++ b/lib/system/jssys.nim
@@ -37,9 +37,6 @@ type
 
 var
   framePtr {.importc, nodecl, volatile.}: PCallFrame
-  excHandler {.importc, nodecl, volatile.}: PSafePoint = nil
-    # list of exception handlers
-    # a global variable for the root of all try blocks
   lastJSError {.importc, nodecl, volatile.}: PJSError = nil
 
 {.push stacktrace: off, profiler:off.}
@@ -52,9 +49,7 @@ proc nimCharToStr(x: char): string {.compilerproc.} =
   result[0] = x
 
 proc getCurrentExceptionMsg*(): string =
-  if excHandler != nil and excHandler.exc != nil:
-    return $excHandler.exc.msg
-  elif lastJSError != nil:
+  if lastJSError != nil:
     return $lastJSError.message
   else:
     return ""
@@ -102,29 +97,13 @@ proc rawWriteStackTrace(): string =
 proc raiseException(e: ref Exception, ename: cstring) {.
     compilerproc, asmNoStackFrame.} =
   e.name = ename
-  if excHandler != nil:
-    excHandler.exc = e
-  else:
-    when NimStackTrace:
-      var buf = rawWriteStackTrace()
-    else:
-      var buf = ""
-    if e.msg != nil and e.msg[0] != '\0':
-      add(buf, "Error: unhandled exception: ")
-      add(buf, e.msg)
-    else:
-      add(buf, "Error: unhandled exception")
-    add(buf, " [")
-    add(buf, ename)
-    add(buf, "]\n")
-    alert(buf)
-  asm """throw `e`;"""
+  asm "throw `e`;"
 
 proc reraiseException() {.compilerproc, asmNoStackFrame.} =
-  if excHandler == nil:
+  if lastJSError == nil:
     raise newException(ReraiseError, "no exception to reraise")
   else:
-    asm """throw excHandler.exc;"""
+    asm "throw lastJSError;"
 
 proc raiseOverflow {.exportc: "raiseOverflow", noreturn.} =
   raise newException(OverflowError, "over- or underflow")