Alternative to ESP_ERROR_CHECK
Posted: Tue Feb 14, 2017 2:30 am
The ESP-IDF provides a useful macro called ESP_ERROR_CHECK() that takes a statement as a parameter. If the statement does NOT return ESP_OK, then we assert and log the line. Unfortunately, this doesn't include the error code value that was actually returned by the statement.
Here is an alternative definition which logs the error code in addition to throwing an assertion:
Here is an alternative definition which logs the error code in addition to throwing an assertion:
Code: Select all
#undef ESP_ERROR_CHECK
#define ESP_ERROR_CHECK(x) do { esp_err_t rc = (x); if (rc != ESP_OK) { ESP_LOGE("err", "esp_err_t = %d", rc); assert(0 && #x);} } while(0);