ESP_RETURN_ON_ERROR macro
Macro which can be used to check the error code. If the code is not ESP_OK, it prints the message and returns.
Syntax
#define ESP_RETURN_ON_ERROR(x, log_tag, format, ...) do { \
esp_err_t err_rc_ = (x); \
if (unlikely(err_rc_ != ESP_OK)) { \
ESP_LOGE(log_tag, "%s(%d): " format, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
return err_rc_; \
} \
} while(0)
Examples
ESP_RETURN_ON_ERROR is referenced by 25 libraries and example projects: