tesseract  4.00.00dev
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::ERRCODE ( const char *  string)
inline

Definition at line 77 of file errcode.h.

77  {
78  message = string;
79  } // initialize with string

Member Function Documentation

◆ error()

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

Definition at line 40 of file errcode.cpp.

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

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