add H3_ERROR_END#1065
Conversation
|
Alternatively, AI suggested something like this: typedef enum {
E_SUCCESS = 0,
E_FAILED,
E_DOMAIN,
/* ... */
E_DELETED_DIGIT,
E_COUNT // sentinel for iteration and sizing
} H3ErrorCodes;
#define H3_ERROR_MAX (E_COUNT - 1) |
We could use E_COUNT directly then no? (I also had a similar idea when adding E_INDEX_INVALID but wasn't sure as then it can be referenced externally - though maybe people would want a similar constant) |
|
@isaacbrodsky, any thoughts on which approach you'd prefer? |
Yeah, I suppose we could do something as simple as: typedef enum {
E_SUCCESS = 0,
E_FAILED = 1,
E_DOMAIN = 2,
/* ... */
E_OPTION_INVALID = 15, // Mode or flags argument was not valid
E_INDEX_INVALID = 16, // `H3Index` argument was not valid
H3_ERROR_SENTINEL // sentinel for iteration and sizing
} H3ErrorCodes; |
We do something similar here: h3/src/h3lib/include/coordijk.h Line 82 in b29d820 enum declaration, because I expect the code will be read much more than it will be written, and so I want to make reading it as easy as possible.
|
This last one looks the "best" to me because (1) it's obviously different from the rest because it doesn't get a number assigned and it doesn't start with It could be made even more explicit by putting an inline multi-line comment above the And if we want to be extra clever, the enum could be named |
Define
H3_ERROR_CODE_MAXinh3api.h.into define the range of errors. Keep it updated as we add new errors.Idea: Use this to address @dfellis's comment here: #1063 (comment)