From: Tim Vaughan Date: Fri, 4 Nov 2016 23:51:46 +0000 (+1300) Subject: Added (error) X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=scheme.forth.jl.git;a=commitdiff_plain;h=e0ca5b6fd7381323cb9737f0ca6bfec9ede3eb7d Added (error) --- diff --git a/scheme-primitives.4th b/scheme-primitives.4th index b71b98d..fdb28d3 100644 --- a/scheme-primitives.4th +++ b/scheme-primitives.4th @@ -440,3 +440,19 @@ defer display apply ; make-primitive apply + +( ==== Error System ==== ) + +:noname ( args -- result ) + bold fg red + + nil? if + ." Error." + else + ." Error: " car display + then + + reset-term + + recoverable-exception throw +; make-primitive error diff --git a/scheme.4th b/scheme.4th index f2d7375..bacd8e0 100644 --- a/scheme.4th +++ b/scheme.4th @@ -52,7 +52,7 @@ variable nextexception make-exception recoverable-exception make-exception unrecoverable-exception -: display-warning ( addr count -- ) +: display-exception-msg ( addr count -- ) bold fg red ." Exception: " type @@ -65,7 +65,7 @@ make-exception unrecoverable-exception [compile] if ['] -rot , - ['] display-warning , + ['] display-exception-msg , [compile] then ['] throw , @@ -1709,11 +1709,7 @@ variable gc-stack-depth recoverable-exception of false endof unrecoverable-exception of true endof - \ Rethrow anything else: - throw - - \ If we're still here, loop again - false + throw false endcase until ;