File: error.h

package info (click to toggle)
objconv 2.56%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,300 kB
  • sloc: cpp: 27,039; makefile: 4; sh: 2
file content (51 lines) | stat: -rw-r--r-- 2,431 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/****************************   error.h   ************************************
* Author:        Agner Fog
* Date created:  2006-07-15
* Last modified: 2006-07-15
* Project:       objconv
* Module:        error.h
* Description:
* Header file for error handler error.cpp
*
* Copyright 2006-2008 GNU General Public License http://www.gnu.org/licenses
*****************************************************************************/
#ifndef OBJCONV_ERROR_H
#define OBJCONV_ERROR_H

// Structure for defining error message texts
struct SErrorText {
   int  ErrorNumber;    // Error number
   int  Status;         // bit 0-3 = severity: 0 = ignore, 1 = warning, 2 = error, 9 = abort
                        // bit 8   = error number not found
   char const * Text;   // Error text
};

// General error routine for reporting warning and error messages to STDERR output
class CErrorReporter {
public:
   CErrorReporter();    // Default constructor
   static SErrorText * FindError(int ErrorNumber); // Search for error in ErrorTexts
   void submit(int ErrorNumber); // Print error message
   void submit(int ErrorNumber, int extra); // Print error message with extra info
   void submit(int ErrorNumber, int, int);  // Print error message with two extra numbers inserted
   void submit(int ErrorNumber, char const * extra); // Print error message with extra info
   void submit(int ErrorNumber, char const *, char const *); // Print error message with two extra text fields inserted
   void submit(int ErrorNumber, int, char const *); // Print error message with two extra text fields inserted
   int Number();        // Get number of errors
   int GetWorstError(); // Get highest warning or error number encountered
   void ClearError(int ErrorNumber); // Ignore further occurrences of this error
protected:
   int NumErrors;       // Number of errors detected
   int NumWarnings;     // Number of warnings detected
   int WorstError;      // Highest error number encountered
   int MaxWarnings;     // Max number of warning messages to pring
   int MaxErrors;       // Max number of error messages to print
   void HandleError(SErrorText * err, char const * text); // Used by submit function
};

#ifndef OBJCONV_ERROR_CPP
extern CErrorReporter err;  // Error handling object is in error.cpp
extern SErrorText ErrorTexts[]; // List of error texts
#endif

#endif // #ifndef OBJCONV_ERROR_H