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
Exception in thread "main" jpl.PrologException: PrologException: error(existence_error(source_sink, 'NonExistingFile'), _0) at jpl.Query.get1(Query.java:336) at jpl.Query.hasMoreSolutions(Query.java:258) at Exceptions.main(Exceptions.java:13)
– CapelliC~/pl-devel/packages/jpl/examples/java/Versions$ ./run.sh
I getJPL demo: Versions % /home/carlo/.plrc compiled 0.00 sec, 8 clauses prolog library version; 3.1.4-alpha java library version; 3.1.4-alpha c library version; 3.1.4-alpha BINGO! you appear to have the same version of each library installed
– CapelliC