diff --git a/pl/utils.yap b/pl/utils.yap index c40b826e6..80ce9c2eb 100644 --- a/pl/utils.yap +++ b/pl/utils.yap @@ -65,8 +65,12 @@ call_cleanup(Goal, Catcher, Cleanup) :- '$cleanup_exception'(Exception, exception(Exception), Cleanup) :- !, % whatever happens, let exception go through - catch('$clean_call'(Cleanup),_,true), - throw(Exception). + ( + catch('$clean_call'(Cleanup),_,fail), + fail + ; + throw(Exception) + ). '$cleanup_exception'(Exception, _, _) :- throw(Exception).