Chapter 4. API Guides
This feature is enabled by default, but can be disabled to reduce application binary size. See CON-
FIG_ESP_ERR_TO_NAME_LOOKUP. When this feature is disabled, esp_err_to_name() and
esp_err_to_name_r() are still defined and can be called. In this case, esp_err_to_name() will
return UNKNOWN ERROR, and esp_err_to_name_r() will return Unknown error 0xXXXX(YYYYY),
where 0xXXXX and YYYYY are the hexadecimal and decimal representations of the error code, respectively.
4.7.4 ESP_ERROR_CHECK macro
ESP_ERROR_CHECK() macro serves similar purpose as assert, except that it checks esp_err_t value rather
than a bool condition. If the argument of ESP_ERROR_CHECK() is not equal ESP_OK, then an error message
is printed on the console, and abort() is called.
Error message will typically look like this:
ESP_ERROR_CHECK failed: esp_err_t 0x107 (ESP_ERR_TIMEOUT) at 0x400d1fdf
file: "/Users/user/esp/example/main/main.c" line 20
func: app_main
expression: sdmmc_card_init(host, &card)
Backtrace: 0x40086e7c:0x3ffb4ff0 0x40087328:0x3ffb5010 0x400d1fdf:0x3ffb5030␣
,→0x400d0816:0x3ffb5050
Note: If IDF monitor is used, addresses in the backtrace will be converted to file names and line numbers.
• The first line mentions the error code as a hexadecimal value, and the identifier used for this error in source code.
The latter depends on CONFIG_ESP_ERR_TO_NAME_LOOKUP option being set. Address in the program
where error has occured is printed as well.
• Subsequent lines show the location in the program where ESP_ERROR_CHECK() macro was called, and the
expression which was passed to the macro as an argument.
• Finally, backtrace is printed. This is part of panic handler output common to all fatal errors. See Fatal Errors
for more information about the backtrace.
4.7.5 ESP_ERROR_CHECK_WITHOUT_ABORT macro
ESP_ERROR_CHECK_WITHOUT_ABORT() macro serves similar purpose as ESP_ERROR_CHECK, except that
it won’t call abort().
4.7.6 ESP_RETURN_ON_ERROR macro
ESP_RETURN_ON_ERROR() macro checks the error code, if the error code is not equal ESP_OK, it prints the
message and returns.
4.7.7 ESP_GOTO_ON_ERROR macro
ESP_GOTO_ON_ERROR() macro checks the error code, if the error code is not equal ESP_OK, it prints the
message, sets the local variable ret to the code, and then exits by jumping to goto_tag.
4.7.8 ESP_RETURN_ON_FALSE macro
ESP_RETURN_ON_FALSE() macro checks the condition, if the condition is not equal true, it prints the message
and returns with the supplied err_code.
Espressif Systems 1304
Submit Document Feedback
Release v4.4