18#define ECLASS(CL, A, B) CL,
23#define E2(A, B, C, D) A,
25#define BEGIN_ERRORS() typedef enum {
31#define BEGIN_ERROR_CLASSES() typedef enum {
33#define END_ERROR_CLASSES() \
35 yap_error_class_number
39#define MAX_ERROR_MSG_SIZE 1024
41extern void Yap_InitError__(
const char *file,
const char *
function,
int lineno,
42 yap_error_number e, YAP_Term g, ...);
44 const char *
function,
int lineno,
45 yap_error_number err, YAP_Term wheret, ...);
47extern void Yap_do_warning__(
const char *file,
48 const char *
function,
int lineno,
49 yap_error_number err, YAP_Term wheret, ...);
51extern void Yap_ThrowError__(
const char *file,
const char *
function,
int lineno,
52 yap_error_number err, YAP_Term wheret,
const char *msg, ...)
55#define Yap_NilError(id, ...) \
56Yap_Error__(false, __FILE__, __FUNCTION__, __LINE__, id, TermNil, __VA_ARGS__)
57#define Yap_InitError(id, ...) \
58 Yap_InitError__(__FILE__, __FUNCTION__, __LINE__, id, TermNil, __VA_ARGS__)
60#define Yap_Error(id, inp, ...) \
61 Yap_Error__(false, __FILE__, __FUNCTION__, __LINE__, id, inp, __VA_ARGS__)
63#define Yap_ThrowError(id, inp, ...) \
64 Yap_ThrowError__(__FILE__, __FUNCTION__, __LINE__, id, inp, __VA_ARGS__)
68#define Yap_do_warning(id, inp, ...) \
69 Yap_do_warning__(__FILE__, __FUNCTION__, __LINE__, id, inp, __VA_ARGS__)
76#define Yap_ensure_atom(T0, TF) \
77 { if ( (TF = Yap_ensure_atom__(__FILE__, __FUNCTION__, __LINE__, T0 ) == 0L ) return false; \
81 static Term Yap_ensure_atom__(
const char *fu,
const char *fi,
int line,
85 if (!IsVarTerm(t) && IsAtomTerm(t))
88 Yap_Error__(
false, fu, fi, line, INSTANTIATION_ERROR, t, NULL);
92 Yap_Error__(
false, fu, fi, line, TYPE_ERROR_ATOM, t, NULL);
98#define JMP_LOCAL_ERROR(v, LAB) \
99 if (H + 2 * (v) > ASP - 1024) { \
100 LOCAL_Error_TYPE = RESOURCE_ERROR_STACK; \
101 LOCAL_Error_Size = 2 * (v) * sizeof(CELL); \
105#define LOCAL_ERROR(t, v) \
106 if (HR + (v) > ASP - 1024) { \
107 LOCAL_Error_TYPE = RESOURCE_ERROR_STACK; \
108 LOCAL_Error_Size = 2 * (v) * sizeof(CELL); \
112#define LOCAL_TERM_ERROR(t, v) \
113 if (HR + (v) > ASP - 1024) { \
114 LOCAL_Error_TYPE = RESOURCE_ERROR_STACK; \
115 LOCAL_Error_Size = 2 * (v) * sizeof(CELL); \
119#define AUX_ERROR(t, n, s, TYPE) \
120 if (s + (n + 1) > (TYPE *)AuxSp) { \
121 LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; \
122 LOCAL_Error_Size = n * sizeof(TYPE); \
126#define AUX_TERM_ERROR(t, n, s, TYPE) \
127 if (s + (n + 1) > (TYPE *)AuxSp) { \
128 LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; \
129 LOCAL_Error_Size = n * sizeof(TYPE); \
133#define JMP_AUX_ERROR(n, s, t, TYPE, LAB) \
134 if (s + (n + 1) > (TYPE *)AuxSp) { \
135 LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK; \
136 LOCAL_Error_Size = n * sizeof(TYPE); \
140#define HEAP_ERROR(a, TYPE) \
142 LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; \
143 LOCAL_Error_Size = n * sizeof(TYPE); \
147#define HEAP_TERM_ERROR(a, TYPE, n) \
149 LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; \
150 LOCAL_Error_Size = n * sizeof(TYPE); \
154#define JMP_HEAP_ERROR(a, n, t, TYPE, LAB) \
156 LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP; \
157 LOCAL_Error_Size = n * sizeof(TYPE); \
166 typedef enum yap_error_status {
168 YAP_NO_ERROR_STATUS = 0x0,
170 YAP_ERROR_INITIATED_IN_PROLOG = 0x1,
172 YAP_ERROR_INITIATED_IN_BOOT = 0x2,
174 YAP_ERROR_INITIATED_IN_HELPER = 0x4,
176 YAP_ERROR_INITIATED_IN_SYSTEM_C = 0x8,
178 YAP_ERROR_INITIATED_IN_USER_C = 0x10,
180 YAP_THROW_THROWN = 0x20,
182 YAP_THROW_CAUGHT = 0x40,
184 YAP_ERROR_EXPORTED_TO_CXX = 0x80,
186 YAP_ERROR_BEING_PROCESSED_IN_PROLOG = 0x100
193 intptr_t prologPredCl;
194 uintptr_t prologPredLine;
195 uintptr_t prologPredFirstLine;
196 uintptr_t prologPredLastLine;
197 const char *prologPredName;
198 uintptr_t prologPredArity;
199 const char *prologPredModule;
200 const char *prologPredFile;
201 struct error_prolog_source *errorParent;
234 uintptr_t parserFirstPos;
235 uintptr_t parserLastPos;
236 uintptr_t parserLine;
237 uintptr_t parserFirstLine;
238 uintptr_t parserLastLine;
239 const char *parserTextA;
241 const char *parserFile;
246 const char * culprit;
247 YAP_Term errorUserTerm, culprit_t;
256#define LOCAL_Error_TYPE LOCAL_ActiveError->errorNo
257#define LOCAL_Error_File LOCAL_ActiveError->errorFile
258#define LOCAL_Error_Function LOCAL_ActiveError->errorFunction
259#define LOCAL_Error_Lineno LOCAL_ActiveError->errorLine
260#define LOCAL_Error_Size LOCAL_ActiveError->errorMsgLen
261#define LOCAL_UserTerm LOCAL_ActiveError->errorUserTerm
262#define LOCAL_ErrorFullTerm LOCAL_ActiveError->FullErrorTerm
263#define LOCAL_ErrorMessage LOCAL_ActiveError->errorMsg
265 extern void Yap_CatchError(
void);
266 extern void Yap_ThrowExistingError(
void);
272 int lineno, yap_error_number type, YAP_Term where,
const char *msg);
278 YAP_Int ignore_first);
280 extern const char *Yap_dump_stack(
void);
285 extern yap_error_class_number Yap_errorClassNumber(
const char *c);
286 extern char *Yap_errorName(yap_error_number e);
287 extern yap_error_class_number Yap_errorClass(yap_error_number e);
288 extern char *Yap_errorClassName(yap_error_class_number e);
289 extern yap_error_number
Yap_errorNumber(yap_error_class_number,
const char * e) ;
291 extern bool Yap_get_exception(
void);
299 void Yap_must_be_list0(YAP_Term t);
yap_error_number Yap_errorNumber(yap_error_class_number, const char *e)
given a string(s, lookup for a corresponding error class r numbe
YAP_Term Yap_MkFullError(yap_error_descriptor_t *r)
convert a C-error to a Prolog term:
yamop * Yap_Error__(bool throw, const char *file, const char *function, int lineno, yap_error_number type, Term where,...)
Yap_Error This function handles errors in the C code.
void Yap_ThrowError__(const char *file, const char *function, int lineno, yap_error_number type, Term where, const char *msg,...)
Throw an error directly to the error handler.
YAP_Term MkSysError(yap_error_descriptor_t *r)
Wrap the error descriptor as exception/2.
yap_error_descriptor_t * Yap_pushErrorContext(bool pass, yap_error_descriptor_t *new_error, yap_error_descriptor_t *old)
add a new error descriptor, either to the top of the stack, or as the top;
bool Yap_MkErrorRecord(yap_error_descriptor_t *r, const char *file, const char *function, int lineno, yap_error_number type, Term where, const char *s)
complete an error descriptor:
all we need to know about an error/throw
bool parserReadingCode
reading a clause, or called from read?
const char * prologStack
Prolog stack at the time.
uintptr_t prologPredLine
line where error clause defined
uintptr_t parserPos
syntax and other parsing errors
const char * errorFunction
C-function.
const char * errorFile
C-file.
yap_error_number errorNo
error identifier
yap_error_class_number errorClass
kind of error: derived from errorNo;
const char * prologPredName
Prolog predicate that caused the error: name.
char * classAsText
errorClass as text
char * errorAsText
errorNo as text
const char * prologPredFile
Prolog predicate that caused the error:line
bool prologConsulting
whether we are consulting
intptr_t errorLine
c-code that generated the error C-line
const char * prologPredModule
Prolog predicate that caused the error:module
uintptr_t prologPredArity
Prolog predicate that caused the error:arity.
a Prolog goal that caused a bug