We're currently building a library in C that configures itself from tables in EEPROM.
This leaves the possibility however that some caller requests a field that is out of bounds, and the question then is, what can we do about that?
We've been thinking about an optional here, but since we're implementing our own error code, the caller has to actively remind themselves to to check this value, making it easy to miss.
Another option would be to just crash the system, which would prevent the system from running with an invalid configuration, but that would be undesirable because that could put the system into a boot-loop and it would trip up our unit-test system.
Having an enum limiting the input options could also work, were it not that we don't know ahead of time how many entries will be in the tables, and the enum would produce a lot of clutter.
Does anybody have any other ideas on how to handle this?