javaprologswi-prologjpl

Retrieving ERROR and WARNING messages from SWI-Prolog through JPL


I am having some trouble retrieving error and warning messages when using JPL. For example, attempting to consult a non-existing file directly from SWI-Prolog produces the following output:

1 ?- consult('NonExistingFile').
ERROR: source_sink `NonExistingFile' does not exist
true.

However, when executing this query through JPL, no exception is thrown and the hasMoreSolutions() method of the Query class returns true:

Query query = new Query("consult('NonExistingFile')");
query.hasMoreSolutions();

How can I detect that an error has occurred and consulting NonExistingFile.pl has actually failed? The same question applies to retrieving warning messages that don't cause the predicate execution to fail.

Edit: the described situation occurs when using JPL with SWI-Prolog versions up to 6.0.2


Solution

  • The problem regarding consulting errors is resolved when using JPL with SWI-Prolog 6.1.9 (currently the development version). An exception is thrown when attempting to consult a file that does not exist.