Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ERRCODE Class Reference

#include <errcode.h>

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.

77  {
78  message = string;
79  } // 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.

45  {
46  va_list args; // variable args
47  char msg[MAX_MSG];
48  char *msgptr = msg;
49 
50  if (caller != NULL)
51  //name of caller
52  msgptr += sprintf (msgptr, "%s:", caller);
53  //actual message
54  msgptr += sprintf (msgptr, "Error:%s", message);
55  if (format != NULL) {
56  msgptr += sprintf (msgptr, ":");
57  va_start(args, format); //variable list
58  #ifdef _WIN32
59  //print remainder
60  msgptr += _vsnprintf (msgptr, MAX_MSG - 2 - (msgptr - msg), format, args);
61  msg[MAX_MSG - 2] = '\0'; //ensure termination
62  strcat (msg, "\n");
63  #else
64  //print remainder
65  msgptr += vsprintf (msgptr, format, args);
66  //no specific
67  msgptr += sprintf (msgptr, "\n");
68  #endif
69  va_end(args);
70  }
71  else
72  //no specific
73  msgptr += sprintf (msgptr, "\n");
74 
75  // %s is needed here so msg is printed correctly!
76  fprintf(stderr, "%s", msg);
77 
78  int* p = NULL;
79  switch (action) {
80  case DBG:
81  case TESSLOG:
82  return; //report only
83  case TESSEXIT:
84  //err_exit();
85  case ABORT:
86  // Create a deliberate segv as the stack trace is more useful that way.
87  if (!*p)
88  abort();
89  default:
90  BADERRACTION.error ("error", ABORT, NULL);
91  }
92 }
#define MAX_MSG
Definition: errcode.cpp:32
Definition: errcode.h:30
#define NULL
Definition: host.h:144
Definition: errcode.h:27
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:41
const ERRCODE BADERRACTION
Definition: errcode.cpp:31

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