nRF5 SDK v17.1.0
Error code to string converter

This module converts the numeric error code that is returned by nRF5 SDK functions to a string that contains human-readable mnemonic.

This module is intended to be used with the Logger module module, but can be also used in any other application that requires human-readable error codes.

The library contains two functions:

The library does not support generating a special string with the error number for an unknown error, like in the ANSI strerror function. The reason is maintaining library reentrancy and the possiblity of simultaneous calls from different contexts. Providing such an option would require a global buffer that would be broken by simultaneous function calls. To generate an error description, if a description is found, use the nrf_strerror_find function:

ret_code_t ret = nrf_function_call(...);
if (ret != NRF_SUCCESS)
{
char const * p_desc = nrf_strerror_find(ret);
if (p_desc == NULL)
{
/* No human readable form found */
printf("Function return code: UNKNOWN (%x)", ret);
}
else
{
/* Nice - mnemonic like - human readable form found */
printf("Function return code: %s", p_desc);
}
}
Note

The library requires a sorted list of all errors including their string representations. This list is created manually and the fact that it is properly sorted is tested by unit tests.

For API documentation of this module, refer to Error code to string converter.


Documentation feedback | Developer Zone | Subscribe | Updated