Let board implementation choose their error type
ia0 opened this issue · comments
Board errors are too restrictive and some APIs could use more granular errors (in particular for debugging when the platform is known). This could be achieved without losing the generality of the current errors by using namespaces. Errors could be 23-bits (or 31-bits if needed) numbers. This way, it is still possible to distinguish errors from success values using the high bit, and after taking the complement, errors would be "small" negative numbers.
Errors could be split in 2:
- A namespace (using the high 7 or 15 bits). Errors may use zero if they don't fit any namespace.
- An error code (using the low 16 bits). This would be board-specific and may use zero as a generic error code (i.e. only the namespace matters).
Example namespaces:
- 0: Unknown / Generic
- 1: User error
- 2: World error
Example error codes:
- 0: Unknown / Generic
- 1: Invalid argument
- 2: Not found
- 3: Out of bounds
- 4: Not aligned
- etc