Tesseract  3.02
ERRCODE Class Reference

#include <errcode.h>

List of all members.

Public Member Functions

void error (const char *caller, TessErrorLogCode action, const char *format,...) const
 ERRCODE (const char *string)

Detailed Description

Definition at line 69 of file errcode.h.


Constructor & Destructor Documentation

ERRCODE::ERRCODE ( const char *  string) [inline]

Definition at line 77 of file errcode.h.

                              {
    message = string;
  }                            // initialize with string

Member Function Documentation

void ERRCODE::error ( const char *  caller,
TessErrorLogCode  action,
const char *  format,
  ... 
) const

Definition at line 41 of file errcode.cpp.

        {
  va_list args;                  // variable args
  char msg[MAX_MSG];
  char *msgptr = msg;

  if (caller != NULL)
                                 //name of caller
    msgptr += sprintf (msgptr, "%s:", caller);
                                 //actual message
  msgptr += sprintf (msgptr, "Error:%s", message);
  if (format != NULL) {
    msgptr += sprintf (msgptr, ":");
    va_start(args, format);  //variable list
    #ifdef _WIN32
                                 //print remainder
    msgptr += _vsnprintf (msgptr, MAX_MSG - 2 - (msgptr - msg), format, args);
    msg[MAX_MSG - 2] = '\0';     //ensure termination
    strcat (msg, "\n");
    #else
                                 //print remainder
    msgptr += vsprintf (msgptr, format, args);
                                 //no specific
    msgptr += sprintf (msgptr, "\n");
    #endif
    va_end(args);
  }
  else
                                 //no specific
    msgptr += sprintf (msgptr, "\n");

  fprintf(stderr, msg);

  int* p = NULL;
  switch (action) {
    case DBG:
    case TESSLOG:
      return;                    //report only
    case TESSEXIT:
      //err_exit();
    case ABORT:
      // Create a deliberate segv as the stack trace is more useful that way.
      if (!*p)
        abort();
    default:
      BADERRACTION.error ("error", ABORT, NULL);
  }
}

The documentation for this class was generated from the following files: