2017-06-12 18:00:47 +01:00
|
|
|
/**
|
2017-04-07 23:10:59 +01:00
|
|
|
* @file yapie.hh
|
2017-03-20 15:52:48 +00:00
|
|
|
*
|
|
|
|
* @defgroup yap-cplus-error-hanadlinge Errir Handling in the YAP interface.
|
|
|
|
*
|
2017-04-07 23:10:59 +01:00
|
|
|
* @brief this is an attempt at supporting error
|
|
|
|
*
|
2017-03-20 15:52:48 +00:00
|
|
|
* @ingroup yap-cplus-interface
|
|
|
|
* @tableofcontents
|
|
|
|
*
|
2017-04-07 23:10:59 +01:00
|
|
|
* @{
|
2017-03-20 15:52:48 +00:00
|
|
|
*
|
|
|
|
* These classes define an object that we can then throw when an error
|
|
|
|
* or unexoected event interrupts YAP. Often, the object is built by
|
2017-04-07 23:10:59 +01:00
|
|
|
* YAP itself. One can also define one's own error objects.
|
|
|
|
*
|
|
|
|
* Errors will be thrown from the `C++` code, and may be processed in
|
|
|
|
* very different ways. The error object should provide as much data asa
|
|
|
|
* possible.
|
2017-03-20 15:52:48 +00:00
|
|
|
*/
|
|
|
|
|
2014-06-30 14:34:58 +01:00
|
|
|
|
2016-09-21 20:41:23 +01:00
|
|
|
#ifndef YAPIE_HH
|
|
|
|
#define YAPIE_HH
|
2014-06-30 14:34:58 +01:00
|
|
|
|
2017-06-12 18:00:47 +01:00
|
|
|
class X_API YAPPPredicate;
|
|
|
|
class X_API YAPTerm;
|
2016-09-21 20:41:23 +01:00
|
|
|
|
|
|
|
/// take information on a Prolog error:
|
2017-06-12 18:00:47 +01:00
|
|
|
class X_API YAPError {
|
2017-02-20 14:38:00 +00:00
|
|
|
yap_error_number ID;
|
|
|
|
std::string goal, info;
|
2016-09-23 03:53:42 +01:00
|
|
|
int swigcode;
|
2017-02-20 14:38:00 +00:00
|
|
|
|
2014-06-30 14:34:58 +01:00
|
|
|
public:
|
2017-02-20 14:38:00 +00:00
|
|
|
YAPError(){
|
|
|
|
//ID = LOCAL_ActiveError->errorNo;
|
|
|
|
}
|
|
|
|
/// error handler object with initial data when receiving the error term
|
|
|
|
YAPError(yap_error_number id, YAPTerm culprit, std::string txt);
|
|
|
|
|
2016-09-21 20:41:23 +01:00
|
|
|
/// we just know the error number
|
|
|
|
/// exact error ID
|
2016-10-20 04:44:59 +01:00
|
|
|
yap_error_number getID() { return LOCAL_ActiveError->errorNo; };
|
2016-09-21 20:41:23 +01:00
|
|
|
/// class of error
|
|
|
|
yap_error_class_number getErrorClass() {
|
2016-10-20 04:44:59 +01:00
|
|
|
return Yap_errorClass(LOCAL_ActiveError->errorNo);
|
2016-09-21 20:41:23 +01:00
|
|
|
};
|
|
|
|
/// where in the code things happened;
|
2016-10-20 04:44:59 +01:00
|
|
|
const char *getFile() { return LOCAL_ActiveError->errorFile; };
|
2016-09-21 20:41:23 +01:00
|
|
|
/// predicate things happened;
|
2016-10-20 04:44:59 +01:00
|
|
|
Int getLine() { return LOCAL_ActiveError->errorLine; };
|
2016-09-21 20:41:23 +01:00
|
|
|
/// the term that caused the bug
|
2016-10-20 04:44:59 +01:00
|
|
|
// YAPTerm getCulprit(LOCAL_ActiveError->errorFile){};
|
2016-09-21 20:41:23 +01:00
|
|
|
/// text describing the Error
|
2017-02-20 14:38:00 +00:00
|
|
|
std::string text();
|
2014-07-10 15:07:55 +01:00
|
|
|
};
|
2014-06-30 14:34:58 +01:00
|
|
|
|
2016-09-21 20:41:23 +01:00
|
|
|
#endif
|
2017-03-20 15:52:48 +00:00
|
|
|
|
|
|
|
/// @}
|