QP_exception_term()
#include <quintus/quintus.h> int QP_exception(term) QP_term_ref term;
A function that users can call when their call to Prolog
signals an error. If QP_query()
returns QP_ERROR
then users can
call QP_exception_term()
to get at the exception term
signalled.
If C calls Prolog and the Prolog goal raises
an exception, QP_query()
(or QP_next_solution()
) returns the value
QP_ERROR
. If the user wants to get at the exception term that has
been raised, they can call the function QP_exception_term()
.
QP_exception_term()
takes a QP_term_ref
as argument and returns a
Prolog term.
foo.pl:- extern(error). error :- raise_exception(error_term(from_prolog)).
foo.cQP_pred_ref pred; if ((pred = QP_predicate("error",0,"user")) != (QP_pred_ref) QP_ERROR) { if (QP_query(pred) == QP_ERROR) { QP_term_ref err_term = QP_new_term_ref(); QP_exception_term(err_term); } }
Once you get err_term
, you can use functions such as the QP_get_*()
family to take apart the error term or to print it.
QP_query()
, QP_next_solution()
, raise_exception/3
ref-ere