separate c++ from c error handling
This commit is contained in:
parent
95bbdc8a17
commit
f960c404aa
@ -379,7 +379,7 @@ YAPPredicate::YAPPredicate(const char *s, Term **outp, term_t &vnames) throw (in
|
||||
vnames = Yap_NewSlots(1 PASS_REGS);
|
||||
Term t = Yap_StringToTerm(s, strlen(s)+1, vnames);
|
||||
if (t == 0L)
|
||||
throw SYNTAX_ERROR;
|
||||
throw YAPError::YAP_SYNTAX_ERROR;
|
||||
ap = getPred( t, outp );
|
||||
//{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "OUT vnames=%d ap=%p LCL0=%p", vnames, ap, LCL0) ; }
|
||||
}
|
||||
@ -575,7 +575,6 @@ displayWithJava(int c)
|
||||
Yap_AndroidBufp[Yap_AndroidSz] = '\0';
|
||||
if (c == '\n' ) {
|
||||
Yap_AndroidBufp[Yap_AndroidSz] = '\0';
|
||||
__android_log_print(ANDROID_LOG_INFO, __FUNCTION__, "after char %c:%s %p",c, Yap_AndroidBufp, curren);
|
||||
curren->run(Yap_AndroidBufp);
|
||||
Yap_AndroidSz = 0;
|
||||
}
|
||||
@ -636,8 +635,8 @@ YAPQuery *YAPEngine::safeQuery( char *s ) {
|
||||
n->resetFlag( PL_Q_PASS_EXCEPTION );
|
||||
return n;
|
||||
}
|
||||
catch (yap_error_number errno) {
|
||||
error = errno;
|
||||
catch (YAPError yerr) {
|
||||
yerror = yerr;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
12
CXX/yapi.hh
12
CXX/yapi.hh
@ -59,6 +59,8 @@ extern "C" {
|
||||
|
||||
#include "YapText.h"
|
||||
|
||||
#include "yapie.hh"
|
||||
|
||||
#if HAVE_STDARG_H
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
@ -421,7 +423,7 @@ public:
|
||||
Term t, tp;
|
||||
t = YAP_ReadBuffer(s,&tp);
|
||||
if (t == 0L)
|
||||
throw SYNTAX_ERROR;
|
||||
throw YAPError::YAP_SYNTAX_ERROR;
|
||||
ap = getPred( t, (Term **)NULL );
|
||||
}
|
||||
|
||||
@ -433,7 +435,7 @@ public:
|
||||
Term t, tp;
|
||||
t = YAP_ReadBuffer(s,&tp);
|
||||
if (t == 0L)
|
||||
throw SYNTAX_ERROR;
|
||||
throw YAPError::YAP_SYNTAX_ERROR;
|
||||
ap = getPred( t, (Term **)NULL );
|
||||
}
|
||||
|
||||
@ -551,7 +553,7 @@ class YAPEngine {
|
||||
private:
|
||||
YAPCallback *_callback;
|
||||
YAP_init_args init_args;
|
||||
yap_error_number error;
|
||||
YAPError yerror;
|
||||
public:
|
||||
YAPEngine(char *savedState = (char *)NULL,
|
||||
size_t stackSize = 0,
|
||||
@ -575,12 +577,12 @@ public:
|
||||
void run() { if (_callback) _callback->run(); }
|
||||
/// execute the callback with a text argument.
|
||||
void run( char *s) { if (_callback) _callback->run(s); }
|
||||
/// execute the callback with a text argument.
|
||||
YAPError hasError( ) { return yerror; }
|
||||
/// build a query on the engine
|
||||
YAPQuery *query( char *s );
|
||||
/// build a query on the engine handling exceptions
|
||||
YAPQuery *safeQuery( char *s );
|
||||
|
||||
yap_error_number hasError( ); //> report whether the engine has found an error
|
||||
};
|
||||
|
||||
/*
|
||||
|
32
CXX/yapie.hh
32
CXX/yapie.hh
@ -10,27 +10,15 @@ class YAPPredicate;
|
||||
|
||||
class YAPError {
|
||||
public:
|
||||
static const int SYNTAX_ERROR = 0x10000; //> syntax error
|
||||
static const int DOMAIN_ERROR = 0x20000; //> usually illegal parameter, like asin( 2 )
|
||||
static const int TYPE_ERROR = 0x40000; //> usually illegal parameter in the language, like ( 2 mod 3.0 )
|
||||
static const int PERMISSION_ERROR = 0x80000; //> wrong para,eter
|
||||
static const int EVALUATION_ERROR = 0x100000; //> bad arithmetic expressions
|
||||
static const int RESOURCE_ERROR = 0x200000; //> no resource available, like MEM
|
||||
static const int REPRESENTATION_ERROR = 0x400000; //> bad UTF-8 strings, etc
|
||||
static const int EXISTËNCE_ERROR = 0x400000; //> object not found
|
||||
static const int PROFILER = 0x400000; //> improve profiling support.
|
||||
static const int OTHER_ERROR = 0x800000; //> anything rldr.,,,,,,,,,,,,,,,,,,,,
|
||||
};
|
||||
|
||||
class YAPErrorClass {
|
||||
public:
|
||||
static const int SYNTAX_ERROR = 0x10000;
|
||||
static const int DOMAIN_ERROR = 0x20000;
|
||||
static const int TYPE_ERROR = 0x40000;
|
||||
static const int PERMISSION_ERROR = 0x80000;
|
||||
static const int EVALUATION_ERROR = 0x100000;
|
||||
static const int RESOURCE_ERROR = 0x200000;
|
||||
static const int REPRESENTATION_ERROR = 0x400000;
|
||||
static const int OTHER_ERROR = 0x800000;
|
||||
static const int YAP_SYNTAX_ERROR = 0x10000; //> syntax error
|
||||
static const int YAP_DOMAIN_ERROR = 0x20000; //> usually illegal parameter, like asin( 2 )
|
||||
static const int YAP_TYPE_ERROR = 0x40000; //> usually illegal parameter in the language, like ( 2 mod 3.0 )
|
||||
static const int YAP_PERMISSION_ERROR = 0x80000; //> wrong para,eter
|
||||
static const int YAP_EVALUATION_ERROR = 0x100000; //> bad arithmetic expressions
|
||||
static const int YAP_RESOURCE_ERROR = 0x200000; //> no resource available, like MEM
|
||||
static const int YAP_REPRESENTATION_ERROR = 0x400000; //> bad UTF-8 strings, etc
|
||||
static const int YAP_EXISTENCE_ERROR = 0x800000; //> object not found
|
||||
static const int YAP_PROFILER = 0x100000; //> improve profiling support.
|
||||
static const int YAP_OTHER_ERROR = 0x2000000; //> anything
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user