Added forth-level exception handling to repl.
[scheme.forth.jl.git] / catch-throw.4th
index 5c66df3..9192082 100644 (file)
@@ -1,6 +1,7 @@
 \ Exception handling
 
 variable handler
+0 handler !
 
 : catch ( cfa -- exception# | 0 )
     psp@ >R
@@ -15,7 +16,12 @@ variable handler
 : throw ( ... exception# -- ... exception# )
     ?dup 0= if exit then
 
-    handler @ rsp!
+    handler @ ?dup 0= if
+        ." Aborting: Uncaught exception " . ." ." cr
+        abort
+    then
+
+    rsp!
     R> handler !
     
     R> swap >R