error_handling

This commit is contained in:
Vítor Santos Costa 2016-01-31 11:54:45 +00:00
parent c9babdd03e
commit 3de5b2c2de
4 changed files with 14 additions and 14 deletions

View File

@ -1 +0,0 @@
M-x

View File

@ -1100,7 +1100,7 @@ atom_concat2( USES_REGS1 )
error: error:
/* Error handling */ /* Error handling */
if (LOCAL_Error_TYPE) { if (LOCAL_Error_TYPE) {
if (Yap_HandleError( "string_code/3" )) { if (Yap_HandleError( "atom_concat/2" )) {
goto restart_aux; goto restart_aux;
} else { } else {
return FALSE; return FALSE;

View File

@ -163,7 +163,7 @@ bool Yap_PrintWarning(Term twarning) {
return rc; return rc;
} }
int Yap_HandleError(const char *s, ...) { bool Yap_HandleError__(const char *file, const char *function, int lineno, const char *s, ...) {
CACHE_REGS CACHE_REGS
yap_error_number err = LOCAL_Error_TYPE; yap_error_number err = LOCAL_Error_TYPE;
const char *serr; const char *serr;
@ -177,28 +177,28 @@ int Yap_HandleError(const char *s, ...) {
switch (err) { switch (err) {
case RESOURCE_ERROR_STACK: case RESOURCE_ERROR_STACK:
if (!Yap_gc(2, ENV, gc_P(P, CP))) { if (!Yap_gc(2, ENV, gc_P(P, CP))) {
Yap_Error(RESOURCE_ERROR_STACK, ARG1, serr); Yap_Error__(file, function, lineno, RESOURCE_ERROR_STACK, ARG1, serr);
return (FALSE); return false;
} }
return TRUE; return true;
case RESOURCE_ERROR_AUXILIARY_STACK: case RESOURCE_ERROR_AUXILIARY_STACK:
if (LOCAL_MAX_SIZE < (char *)AuxSp - AuxBase) { if (LOCAL_MAX_SIZE < (char *)AuxSp - AuxBase) {
LOCAL_MAX_SIZE += 1024; LOCAL_MAX_SIZE += 1024;
} }
if (!Yap_ExpandPreAllocCodeSpace(0, NULL, TRUE)) { if (!Yap_ExpandPreAllocCodeSpace(0, NULL, TRUE)) {
/* crash in flames */ /* crash in flames */
Yap_Error(RESOURCE_ERROR_AUXILIARY_STACK, ARG1, serr); Yap_Error__(file, function, lineno, RESOURCE_ERROR_AUXILIARY_STACK, ARG1, serr);
return FALSE; return false;
} }
return TRUE; return true;
case RESOURCE_ERROR_HEAP: case RESOURCE_ERROR_HEAP:
if (!Yap_growheap(FALSE, 0, NULL)) { if (!Yap_growheap(FALSE, 0, NULL)) {
Yap_Error(RESOURCE_ERROR_HEAP, ARG2, serr); Yap_Error__(file, function, lineno, RESOURCE_ERROR_HEAP, ARG2, serr);
return FALSE; return false;
} }
default: default:
Yap_Error(err, LOCAL_Error_Term, serr); Yap_Error__(file, function, lineno, err, LOCAL_Error_Term, serr);
return (FALSE); return false;
} }
} }

View File

@ -176,7 +176,8 @@ void Yap_RestartYap(int);
void Yap_exit(int); void Yap_exit(int);
bool Yap_Warning(const char *s, ...); bool Yap_Warning(const char *s, ...);
bool Yap_PrintWarning(Term t); bool Yap_PrintWarning(Term t);
int Yap_HandleError(const char *msg, ...); bool Yap_HandleError__(const char *file, const char *function, int lineno, const char *s, ...);
#define Yap_HandleError(...) Yap_HandleError__(__FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
int Yap_SWIHandleError(const char *, ...); int Yap_SWIHandleError(const char *, ...);
void Yap_InitErrorPreds(void); void Yap_InitErrorPreds(void);