问题描述
在使用 JPL 时,我在检索错误和警告消息时遇到了一些问题.例如,尝试直接从 SWI-Prolog 查询不存在的文件会产生以下输出:
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.
但是,当通过 JPL 执行此查询时,没有抛出异常并且 Query 类的 hasMoreSolutions() 方法返回 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();
如何检测到发生了错误并且查询 NonExistingFile.pl 实际上失败了?同样的问题适用于检索不会导致谓词执行失败的警告消息.
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.
当使用 JPL 和 SWI-Prolog 版本高达 6.0.2 时,会发生所描述的情况
推荐答案
在使用 JPL 和 SWI-Prolog 6.1.9(目前是开发版本)时,关于咨询错误的问题得到解决.尝试查询不存在的文件时会引发异常.
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.
这篇关于通过 JPL 从 SWI-Prolog 检索 ERROR 和 WARNING 消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!