I am writing a simple parser to read a configuration file. The config.h interface has only three main functions; they are briefly described below.
config_init(); config_dinit(); config_parse(); config_read_value();
My question is that these functions will emit different types of errors, for example,
config_init() emit , FILE_NOT_FOUND,FILE_EOF_ERROR,FILE_OPEN_ERROR, ... config_dinit() emit , NOT_INIT_ERROR , config_parse() emit , PARSE_ERROR, OVERFLOW_ERROR, INVALID_CHARACTER_FOUND_ERROR,... config_read_value() emit, SECTION_NOT_FOUND,KEYWORD_NOT_FOUND,OVERFLOW_ERROR,NOT_INITIALIZED_ERROR,INVALID_STATE_ERROR,... etc. Then I create enums for each function, for by using these names , enum Config_ParseError{...} , enum Config_InitError{...} ,enum Config_ReadValueError{..} etc.
Some enumeration values โโoverlap and also remove the "compiler error". like OVERFLOW_ERROR,
I open your suggestions,
and I did a little research on Google and found that the most popular IRC client source code identified listings like this,
enum { CMDERR_OPTION_UNKNOWN = -3, CMDERR_OPTION_AMBIGUOUS = -2, CMDERR_OPTION_ARG_MISSING = -1, CMDERR_UNKNOWN, CMDERR_AMBIGUOUS, CMDERR_ERRNO, CMDERR_NOT_ENOUGH_PARAMS, CMDERR_NOT_CONNECTED, CMDERR_NOT_JOINED, CMDERR_CHAN_NOT_FOUND, CMDERR_CHAN_NOT_SYNCED, CMDERR_ILLEGAL_PROTO, CMDERR_NOT_GOOD_IDEA, CMDERR_INVALID_TIME, CMDERR_INVALID_CHARSET, CMDERR_EVAL_MAX_RECURSE, CMDERR_PROGRAM_NOT_FOUND };
it defines an enumeration without any name, is that a good style? Then why what are the reasons for what?
Seriously need some more good naming solutions. Please do not hurt me, I just start reading the book "write a beautiful book C".
Thanks in advance. Sandun.