0
votes

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

1
I tried, but I got the exception: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
That is very interesting. I'm only getting this error message in the default error stream (System.err): "ERROR: source_sink `NonExistingFile' does not exist". But no exception is thrown. What versions of SWI-Prolog/JPL are you using?Epicurus
I try to keep just the latest. I'm running Linux and I always build from source with default setting. Jan released 2 or 3 days ago an update, I have still to upgrade...When I run ~/pl-devel/packages/jpl/examples/java/Versions$ ./run.sh I get JPL 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 installedCapelliC

1 Answers

1
votes

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.