bakerstu / openmrn

OpenMRN (Open Model Railroad Network)
BSD 2-Clause "Simplified" License
57 stars 29 forks source link

Move standardized error codes out of ::openlcb:: #411

Open balazsracz opened 4 years ago

balazsracz commented 4 years ago

Currently the only useful error enumeration in OpenMRN lives inside the openlcb::Defs class. This means that any openmrn component that needs to return errors is facing two unpleasant choices:

We need to discuss what would be a good way out of this. A requirement is that our error codes remain harmonized to the OpenLCB standard, i.e., the actual values should not change and be used by the ::openlcb:: namespace components as well. A desirable property is to have the ability to project any openmrn error code to an openlcb error code for transmitting through the network.

balazsracz commented 4 years ago

Probably the minimum acceptable solution here is to move the error enum into its own file under util/ErrorCodes.hxx and out of the openlcb namespace.

As some more advanced topic, we should look at encoding two things in the upper 16 bits of the error code: 1 - if this error code is openlcb compatible 2 - which component generated this error code, so as to allow looking up definition and comments in that specific components' documentation.

bakerstu commented 4 years ago

I like these suggestions.