Throughout the SDK there are functions that assign the same error value to multiple different error conditions. An random example is this code from the octal spi driver
The same error value is assigned to two different error conditions. This seems to be repeated throughout the code base.
This would be considered very poor code in my organization as the only way to debug the code is to instrument the API code with breakpoints every time an error is encountered. Downstream code is unable to do anything intelligent with the error and if the error condition needs to be caught and handled, the validation check code has to be rewritten in dowstream functions.
What is the recommend way to catch and debug errors in user code? Maybe there's a technique I'm unaware of?