C API/Implementation of error handling

Define:

1. ECLASS:

1. /0:

1. E:

1. /1:

1. ES:

1. /2:

1. BEGIN_ERRORS:

1. END_ERRORS:

1. BEGIN_ERROR_CLASSES:

1. END_ERROR_CLASSES:

1. MAX_ERROR_MSG_SIZE:

1. Yap_NilError:

1. Yap_InitError:

1. Yap_Error:

1. Yap_ThrowError:

1. Yap_syntax_error:

1. Yap_do_warning:

1. JMP_LOCAL_ERROR:

1. LOCAL_ERROR:

1. LOCAL_TERM_ERROR:

1. AUX_ERROR:

1. AUX_TERM_ERROR:

1. JMP_AUX_ERROR:

1. HEAP_ERROR:

1. HEAP_TERM_ERROR:

1. JMP_HEAP_ERROR:

1. LOCAL_Error_TYPE: : compatibility with existing code..

1. LOCAL_Error_File:

1. LOCAL_Error_Function:

1. LOCAL_Error_Lineno:

1. LOCAL_Error_Size:

1. LOCAL_UserTerm:

1. LOCAL_ErrorFullTerm:

1. LOCAL_ErrorMessage:

1. Yap_HandleError:

Functions:

1. void Yap_InitError__(const char file, const char function, int lineno, yap_error_number e, YAP_Term g, const char *msg,...):

1. struct yami * Yap_Error__(bool thrw, const char file, const char function, int lineno, yap_error_number err, YAP_Term wheret, const char *fmt,...):

1. void Yap_do_warning__(const char file, const char function, int lineno, yap_error_number err, YAP_Term wheret, const char *fmt,...):

1. void Yap_ThrowError__(const char file, const char function, int lineno, yap_error_number err, YAP_Term wheret, const char *msg,...):

1. void Yap_CatchError(void):

1. void Yap_ThrowExistingError(void): : complete delayed error.

1. YAP_Term Yap_MkPrologError(YAP_Term t, yap_error_descriptor_t *wi):

1. YAP_Term MkSysError(yap_error_descriptor_t *r): : Wrap the error descriptor as exception/2.

1. YAP_Term Yap_MkFullError(yap_error_descriptor_t *r, yap_error_number e): : convert a C-error to a Prolog term:

  • fill text fields

  • wrap descriptor1240

1. bool Yap_MkErrorRecord(yap_error_descriptor_t r, const char file, const char function, int lineno, yap_error_number type, YAP_Term where, YAP_Term extra, const char msg):

1. yap_error_descriptor_t * Yap_pc_add_location(yap_error_descriptor_t t, void pc0, void b_ptr0, void env0):

1. yap_error_descriptor_t * Yap_env_add_location(yap_error_descriptor_t t, void cp0, void b_ptr0, void env0, YAP_Int ignore_first):

1. yap_error_descriptor_t * Yap_prolog_add_culprit(yap_error_descriptor_t *t):

1. yap_error_class_number Yap_errorClassNumber(const char *c):

1. char * Yap_errorName(yap_error_number e):

1. char * Yap_errorNam/2(yap_error_number e):

1. yap_error_class_number Yap_errorClass(yap_error_number e):

1. char * Yap_errorClassName(yap_error_class_number e):

1. yap_error_number Yap_errorNumber(yap_error_class_number, const char e, const char e2): : given a string(s, lookup for a corresponding error class r numbe

given a string(s) and class context, lookup for a corresponding error number

1. bool Yap_get_exception(void):

1. YAP_Term Yap_UserError(YAP_Term t, yap_error_descriptor_t *i):

1. 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;

1. yap_error_descriptor_t * Yap_popErrorContext(bool oerr, bool pass, yap_error_descriptor_t *):

1. YAP_Term Yap_MkErrorYAP_Term(struct s_yap_error_descriptor *t):

1. bool Yap_Warning(const char *s,...):

1. bool Yap_PrintWarning(YAP_Term t, YAP_Term level):

1. bool Yap_HandleError__(const char file, const char function, int lineno, const char *s,...):

1. int Yap_SWIHandleError(const char *,...):

1. void Yap_InitErrorPreds(void):

1. bool Yap_callable(YAP_Term t):

1. bool Yap_must_be_callable(YAP_Term t, YAP_Term mod):

1. char * Yap_syntax_error__(const char file, const char function, int lineno, YAP_Term t, int sno, TokEntry start, TokEntry err, char *s,...):

Typedef:

1. typedef enum yap_error_status yap_error_stage_t: : Error stages since it was initially processed.

Notice that some of the stages may be active simultaneouly.

1. typedef struct yap_error_prolog_source yap_error_prolog_source_t: : a Prolog goal that caused a bug

1. typedef struct s_yap_error_descriptor yap_error_descriptor_t: : all we need to know about an error/throw

Enum:

1. yap_error_status: : Error stages since it was initially processed.

Notice that some of the stages may be active simultaneouly.