Error Codes and Helper Functions¶
This section lists definitions of common ESP-IDF error codes and several helper functions related to error handling.
For general information about error codes in ESP-IDF, see Error Handling.
For the full list of error codes defined in ESP-IDF, see Error Code Reference.
API Reference¶
Header File¶
Functions¶
-
const char *
esp_err_to_name
(esp_err_t code)¶ Returns string for esp_err_t error codes.
This function finds the error code in a pre-generated lookup-table and returns its string representation.
The function is generated by the Python script tools/gen_esp_err_to_name.py which should be run each time an esp_err_t error is modified, created or removed from the IDF project.
- Return
string error message
- Parameters
code
: esp_err_t error code
-
const char *
esp_err_to_name_r
(esp_err_t code, char *buf, size_t buflen)¶ Returns string for esp_err_t and system error codes.
This function finds the error code in a pre-generated lookup-table of esp_err_t errors and returns its string representation. If the error code is not found then it is attempted to be found among system errors.
The function is generated by the Python script tools/gen_esp_err_to_name.py which should be run each time an esp_err_t error is modified, created or removed from the IDF project.
- Return
buf containing the string error message
- Parameters
code
: esp_err_t error code[out] buf
: buffer where the error message should be writtenbuflen
: Size of buffer buf. At most buflen bytes are written into the buf buffer (including the terminating null byte).
Macros¶
-
ESP_OK
¶ esp_err_t value indicating success (no error)
-
ESP_FAIL
¶ Generic esp_err_t code indicating failure
-
ESP_ERR_NO_MEM
¶ Out of memory
-
ESP_ERR_INVALID_ARG
¶ Invalid argument
-
ESP_ERR_INVALID_STATE
¶ Invalid state
-
ESP_ERR_INVALID_SIZE
¶ Invalid size
-
ESP_ERR_NOT_FOUND
¶ Requested resource not found
-
ESP_ERR_NOT_SUPPORTED
¶ Operation or feature not supported
-
ESP_ERR_TIMEOUT
¶ Operation timed out
-
ESP_ERR_INVALID_RESPONSE
¶ Received response was invalid
-
ESP_ERR_INVALID_CRC
¶ CRC or checksum was invalid
-
ESP_ERR_INVALID_VERSION
¶ Version was invalid
-
ESP_ERR_INVALID_MAC
¶ MAC address was invalid
-
ESP_ERR_WIFI_BASE
¶ Starting number of WiFi error codes
-
ESP_ERR_MESH_BASE
¶ Starting number of MESH error codes
-
ESP_ERR_FLASH_BASE
¶ Starting number of flash error codes
-
ESP_ERR_HW_CRYPTO_BASE
¶ Starting number of HW cryptography module error codes
-
ESP_ERROR_CHECK
(x)¶ Macro which can be used to check the error code, and terminate the program in case the code is not ESP_OK. Prints the error code, error location, and the failed statement to serial output.
Disabled if assertions are disabled.
-
ESP_ERROR_CHECK_WITHOUT_ABORT
(x)¶ Macro which can be used to check the error code. Prints the error code, error location, and the failed statement to serial output. In comparison with ESP_ERROR_CHECK(), this prints the same error message but isn’t terminating the program.