Efficient way of defining error codes
Posted on 2010-09-14
I am currently working on a big existing software architecture in C++. It has error codes in the header file defined something like this:
static const int ERROR_ABC -1;
static const int ERROR_PQR -2;
static const int ERROR_XYZ -3;
Since -1, -2, etc values are clashing with some numerical results after the code was modified recently, I have been asked to come up with a more efficient method to handle error codes. Please give your suggestions (preferably with examples) to solve this problem. One idea I got was to change -1, -2 etc in the header file to something bigger like 100001, 100002, etc. Not sure if this is really a good way.