diff options
author | Peter Mikkelsen <peter@pmikkelsen.com> | 2021-07-01 19:55:40 +0000 |
---|---|---|
committer | Peter Mikkelsen <peter@pmikkelsen.com> | 2021-07-01 19:55:40 +0000 |
commit | e5ab41faf611c61878ad792cbaaf0294cd5715dd (patch) | |
tree | 20bc65a2669645ba3eae9b9d3b9165ecf03c9bcf /example.pl | |
parent | 329c6975c44fcbe1cf7c9d93ab6164495f432213 (diff) |
Add exceptions :) implement catch/3 and throw/1
Diffstat (limited to 'example.pl')
-rw-r--r-- | example.pl | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -22,3 +22,16 @@ curly(A) :- A = {one,two,three}. tester(A, B) :- !, A = B. tester(A, B) :- true. + +thrower(_, 10). +thrower(_, 20). +thrower(inner, _) :- throw(number(30)). +thrower(outer, _) :- throw(hehe). +thrower(_, 100). + +throwtest(Type, L) :- + catch( + catch((thrower(Type, N), L=N), number(N), L=N), + Other, + L=outer_exception(Other) + ). |