I played with several other examples that I found. This may be helpful.
p :- throw(b). r(X) :- throw(X). q:- catch(p, B, format('Output1: Error from throwing p')), r(B). catch(throw(exit(1)), exit(X), format('Output: `w', [X])). Output: 1 1 is thrown to catcher 'exit(X)' and recovered by format('Output: ~w', [X])), catch(p, C, format('hellop')). Output: hellop p throws 'b' which is recovered by writing 'hellop' catch(q, C, format('Output2, Recovering q: helloq ')). Output1: Error from throwing p Output2, Recovering q: helloq
Ben
source share