Zero  0.1.0
Files | Enumerations
Error code and error messages

Error codes and corresponding error messages defined in w_error_xmacro.h. More...

Files

file  w_error_xmacro.h
 Error code/message definition in X-Macro style.
 
file  w_error_xmacro.h
 Error code/message definition in X-Macro style.
 

Enumerations

enum  w_error_codes { w_error_ok = 0, X }
 Enum of error codes defined in w_error_xmacro.h. More...
 

Detailed Description

Error codes and corresponding error messages defined in w_error_xmacro.h.

Quick-start

To return an error, just put "return RC(error_code_here);". Whenever you want a new error message, append a new line in w_error_xmacro.h like existing lines. This file is completely independent and header-only. Just include w_error.h to use.

History

Shore-MT had a perl script to generate equivalent codes from tabular data files. The reason for doing so back then was (I guess) to keep the definition of error code in the same line as the definition of its error message for better readability and maintainability. This is where C++ sucks where pretty-print enum like Java is not available.

X-Macros

However, the code generator unfortunately caused another readability and maintainability issue just for this trivial goal. Foster-Btree changed it to the so-called "X Macro" style. http://en.wikipedia.org/wiki/X_Macro http://www.drdobbs.com/the-new-c-x-macros/184401387 The goal is same, but by using this approach, we don't need code generator.

Pollution

As you might notice, this enum is directly exposed in global namespace. Not a good thing, but otherwise existing code will break. We might move it to some namespace or class member when we are ready to do wide refactoring.

Enumeration Type Documentation

§ w_error_codes

Enum of error codes defined in w_error_xmacro.h.

Enumerator
w_error_ok 

0 means no-error.