RosettaCodeData/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Factor/exceptions-catch-an-exception-thrown-in-a-nested-call.factor
2019-09-12 10:33:56 -07:00

21 lines
395 B
Factor

USING: combinators.extras continuations eval formatting kernel ;
IN: rosetta-code.nested-exceptions
ERROR: U0 ;
ERROR: U1 ;
: baz ( -- )
"IN: rosetta-code.nested-exceptions : baz ( -- ) U1 ;"
( -- ) eval U0 ;
: bar ( -- ) baz ;
: foo ( -- )
[
[ bar ] [
dup T{ U0 } =
[ "%u recovered\n" printf ] [ rethrow ] if
] recover
] twice ;
foo