From 4c47f4188e24c2a1b77026b3998f165f2e6a6577 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Thu, 3 Dec 2009 22:54:31 +0000 Subject: [PATCH] fix exceptions in setup. --- pl/control.yap | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pl/control.yap b/pl/control.yap index 3331e612f..b3577f00d 100644 --- a/pl/control.yap +++ b/pl/control.yap @@ -66,11 +66,17 @@ setup_call_cleanup(Setup, Goal, Cleanup) :- setup_call_catcher_cleanup(Setup, Goal, Catcher, Cleanup) :- yap_hacks:disable_interrupts, - '$check_goal_for_setup_call_cleanup'(Setup, setup_call_catcher_cleanup(Setup, Goal, Catcher, Cleanup)), - '$do_setup'(Setup), - '$check_goal_for_setup_call_cleanup'(Cleanup, setup_call_catcher_cleanup(Setup, Goal, Catcher, Cleanup)), + '$check_goal_for_setup_call_cleanup'(Setup, setup_call_cleanup(Setup, Goal, Cleanup)), + catch('$do_setup'(Setup),Exception,'$handle_broken_setup'(Exception)), + '$check_goal_for_setup_call_cleanup'(Cleanup, setup_call_cleanup(Setup, Goal, Cleanup)), '$safe_call_cleanup'(Goal,Cleanup,Catcher,Exception). +% make sure we don't lose interrupts if we get exceptions +% with setup. +'$handle_broken_setup'(Setup) :- + yap_hacks:enable_interrupts, + throw(Exception). + '$check_goal_for_setup_call_cleanup'(Goal, G) :- strip_module(Goal, _, MG), (