--- gforth/except.fs 2006/05/26 21:18:45 1.10 +++ gforth/except.fs 2006/12/28 20:53:03 1.14 @@ -76,7 +76,16 @@ Defer store-backtrace \ !! explain handler on-stack structure +Variable first-throw +: nothrow ( -- ) \ gforth + \G Use this (or the standard sequence @code{['] false catch drop}) + \G after a @code{catch} or @code{endtry} that does not rethrow; + \G this ensures that the next @code{throw} will record a + \G backtrace. + first-throw on ; + : (try) ( ahandler -- ) + first-throw on r> swap >r \ recovery address rp@ 'catch >r @@ -125,7 +134,10 @@ is catch :noname ( y1 .. ym error/0 -- y1 .. ym / z1 .. zn error ) \ exception ?DUP IF [ here forthstart 9 cells + ! ] - store-backtrace error-stack off + first-throw @ IF + store-backtrace error-stack off + first-throw off + THEN handler @ ?dup-0=-IF >stderr cr ." uncaught exception: " .error cr 2 (bye) @@ -139,7 +151,7 @@ is catch rdrop 'throw r> perform THEN ; is throw -[IFDEF] throw>error +[IFDEF] rethrow :noname ( y1 .. ym error/0 -- y1 .. ym / z1 .. zn error ) \ exception ?DUP IF handler @ ?dup-0=-IF @@ -154,5 +166,5 @@ is throw r> swap >r sp! drop r> rdrop 'throw r> perform THEN ; -is throw>error -[THEN] \ No newline at end of file +is rethrow +[THEN]