« Return to Thread: Trying to understand catch and throw syntax

Trying to understand catch and throw syntax

by Steve Prior :: Rate this Message:

Reply to Author | View in Thread

 From reading the manual section on ISO compliant Exception handling I'm trying
to understand how to use this in my code, so I wrote the following to try it out:

crashme :-
    catch(
           (
              throw(error(formal, context))
           ),
           E,
           (
              print_message(error, E),
              fail
           )
         ).



I expected some kind of message output, but what I got instead was:

2 ?- crashme.
ERROR: Unknown error term: formal
false.


Can someone clarify the syntax of how you might throw an error in pure Prolog code?


Steve


_______________________________________________
SWI-Prolog mailing list
SWI-Prolog@...
https://mailbox.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog

 « Return to Thread: Trying to understand catch and throw syntax