Permalink
Browse files

Hiding large number of errors in msSetError (#4960)

  • Loading branch information...
szekerest committed Jul 23, 2014
1 parent 3e8aa5a commit 8d8f22f4fdcfd61696e34209cbbe9ed9998423e8
Showing with 36 additions and 11 deletions.
  1. +35 −11 maperror.c
  2. +1 −0 maperror.h
@@ -202,6 +202,7 @@ static errorObj *msInsertErrorObj(void)
ms_error->isreported = MS_FALSE;
ms_error->routine[0] = '\0';
ms_error->message[0] = '\0';
ms_error->errorcount = 0;
}
}

@@ -230,6 +231,7 @@ void msResetErrorList()
ms_error->code = MS_NOERR;
ms_error->routine[0] = '\0';
ms_error->message[0] = '\0';
ms_error->errorcount = 0;

/* -------------------------------------------------------------------- */
/* Cleanup our entry in the thread list. This is mainly */
@@ -286,6 +288,18 @@ char *msAddErrorDisplayString(char *source, errorObj *error)
if((source = msStringConcatenate(source, ms_errorCodes[error->code])) == NULL) return(NULL);
if((source = msStringConcatenate(source, " ")) == NULL) return(NULL);
if((source = msStringConcatenate(source, error->message)) == NULL) return(NULL);
if (error->errorcount > 0) {
char* pszTmp;
if((source = msStringConcatenate(source, " (")) == NULL) return(NULL);
pszTmp = msIntToString(error->errorcount);
if((source = msStringConcatenate(source, pszTmp)) == NULL) {
msFree(pszTmp);
return(NULL);
}
msFree(pszTmp);
if((source = msStringConcatenate(source, ")")) == NULL) return(NULL);
}

return source;
}

@@ -311,25 +325,35 @@ char *msGetErrorString(char *delimiter)

void msSetError(int code, const char *message_fmt, const char *routine, ...)
{
errorObj *ms_error = msInsertErrorObj();
errorObj *ms_error;
va_list args;

ms_error->code = code;

if(!routine)
strcpy(ms_error->routine, "");
else {
strlcpy(ms_error->routine, routine, sizeof(ms_error->routine));
}
char message[MESSAGELENGTH];

if(!message_fmt)
strcpy(ms_error->message, "");
strcpy(message, "");
else {
va_start(args, routine);
vsnprintf( ms_error->message, MESSAGELENGTH, message_fmt, args );
vsnprintf( message, MESSAGELENGTH, message_fmt, args );
va_end(args);
}

ms_error = msGetErrorObj();

/* Insert the error to the list if it is not the same as the previous error*/
if (ms_error->code != code || !EQUAL(message, ms_error->message) ||
!EQUAL(routine, ms_error->routine)) {
ms_error = msInsertErrorObj();
if(!routine)
strcpy(ms_error->routine, "");
else {
strlcpy(ms_error->routine, routine, sizeof(ms_error->routine));
}
strlcpy(ms_error->message, message, sizeof(ms_error->message));
ms_error->code = code;
}
else
++ms_error->errorcount;

/* Log a copy of errors to MS_ERRORFILE if set (handled automatically inside msDebug()) */
msDebug("%s: %s %s\n", ms_error->routine, ms_errorCodes[ms_error->code], ms_error->message);

@@ -107,6 +107,7 @@ extern "C" {
char routine[ROUTINELENGTH];
char message[MESSAGELENGTH];
int isreported;
int errorcount; /* number of subsequent errors */
#ifndef SWIG
struct errorObj *next;
#endif

0 comments on commit 8d8f22f

Please sign in to comment.