Skip to content
Error Class Generator
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


This is an Error Class Generator. What it does is take a text file that defines the error types, constant names and messages, levels and responses associated with it and generates classes in the supported languages that can be used to consistently handle the errors. Currently supported languages are:

  • C++
  • Java
  • C

We use this program to generate consistent error codes and messages between a Java client application and a C++ server application.


This is version 1.2.3 of the software. We have tested and are using this for our own software development and have found it to work and be stable. Any comments, bug-fixes or additional features can be sent to the maintainer.


The code itself is under the Gnu General Public License but any code generated by the program can be put under any license you desire. The Gnu Public License is in this archive as license.txt.

The initial development was funded by SecureWorx South Africa (Pty) Ltd. (


Look at errdef.h. You may want to change ERROR_PREFIX. This will prefix all constant names for the C++ error codes.

The code is pretty simple and should compile on any system using gcc.

Run "configure" from the directory you installed the source into followed by "make".


All documentation for this program is handled by Doxygen with one additional .rtf file definition.rtf that defines the input format. Doxygen can be found at


This project is maintained by Robert Sandilands from SecureWorx South Africa (Pty) Ltd. My e-mail address is The Java definitions was done by Andries Malan from SecureWorx and his e-mail address is

Additional contributors:

Adam D. Burry []


errconv --in definition [--c++ --cout cout-base] [--java --jout jout-base] [--c --cnout cnout-base]

--in Points to a text file as defined by definition.rtf and as in the example errors.txt

--c++ States that a C++ class must be generated with the name "cout-base_Errors" contained in the files "cout-base.cpp" and "cout-base.h".

--cout This defines "cout-base" as used to generate the file names and the class name. If there are any directory names part of the path it is ignored when creating the class name.

--java States that Java classes must be generated with the names "jout-baseError", "jout-baseImpLevel", "jout-baseResponse" with the relevant file names.

--jout This defines "jout-base" as used to generate the file names and the class names. If there are any directory names part of the path it is ignored when creating the class name.

--c States that C files must be created with the name "cnout-base.h" and "cnout-base.c".

--cnout This defines the "cnout-base" as used to generate the file names for the C output.

Generated Files


Each error has a name, number, level, response and message. The name is used in the code to define the error. That is when you can't open a file you set the error code to ERROR_PREFIX_NOOPEN where NOOPEN is the name of an error you defined. The number is used in the code but is largely irrelevant. The name and the number must however be unique. The message is a string that can be displayed by the error processing code to help the user of the application understand the error. The level parameter is there to define the seriousness of the error and can be used in conjunction with logging to provide more information to the user. The response value can be used to automate decision making based on the error. This means you can specify whether an error can be safely ignored or whether you can retry or totally abort.

There must be other systems like that out there but there wasn't a system that did customizable error levels, responses, messages and could handle different languages.


The C++ generator generates the files as defined in the parameters to "errconv". A set of constants are defined for use in the program to define the error that occurred. The constant names are "ERROR_PREFIX"_"ERROR_NAME" where ERROR_PREFIX are defined in errdef.h and ERROR_NAME's are defined in the input file. There is a constant "ERROR_PREFIX"_NUM_ERROR that defines the number of errors defined. There is also "ERROR_PREFIX"_LEVEL_DEBUG to "ERROR_PREFIX"_LEVEL_EMERG to define the levels. The generated .h file contains all these definitions. The responses follows the "ERROR_PREFIX"_REPONSE_IGNORE to "ERROR_PREFIX"_RESPONSE_PANIC convention.

The class generated contains static members that will convert the error constant into all the relevant values for you. This means you can easily use the class as is, as a sort of global variable or you can overload the class adding your own error handling functionality based upon the structure created.


The error names become "jout-base"Error."ErrorName". You can recover the message associated with the error by using "jout-base"Error.getErrorString(error code ).

You will have to define your own ErrorObj class that handles the error names, responses and levels and access to that.


The C files generated have four functions. They are "ERROR_PREFIXErrorCode_To_Name", "ERROR_PREFIXErrorCode_To_Level", "ERROR_PREFIXErrorCode_To_Response" and "ERROR_PREFIXErrorCode_To_Message". ERROR_PREFIX is defined in errdef.h. The same constants and definitions are defined as is the case with the C++ classes. It is just not in a class format.

Other languages

No other languages are defined yet, but you are welcome to add any you want.


Makefile - Makefile for program

README - This file

CHANGES - The history of the project

definition.rtf - Defines the structure of the input file

errconv.cpp - The main program

errcpp.cpp - The C++ code generator

errcpp.h - The class definition for errcpp.cpp

errdef.cpp - The input file parser

errdef.h - Global definitions for all files

errjava.cpp - The Java code generator

errjava.h - The class definition for errjava.cpp

errc.cpp - The C code generator

errc.h - The class definition for errc.cpp - The autoconf source file

configure - The generated configuration file - A file for our own site customization.

errors.txt - An example input file

license.txt - The GNU Public License applicable to this code but not to generated code.

Last Changed

1.2.4 - 5 May 2018 by Robert Sandilands.

1.2.3 - 13 June 2003 by Robert Sandilands.

1.2.2 - 3 May 2002 by Robert Sandilands.

1.2.1 - 28 June 2001 by Robert Sandilands and Adam Burry.

1.2.0 - 27 June 2001 by Robert Sandilands.

1.1.0 - 9 March 2001 by Robert Sandilands.

1.0.0 - 6 March 2001 by Robert Sandilands.

You can’t perform that action at this time.