esp_err_to_name (IDFGH-7793) (#78)

fix(esp-modem): Use err_to_name to log error message on error
This commit is contained in:
diplfranzhoepfinger
2022-07-18 17:08:15 +02:00
committed by GitHub
parent 973837dd66
commit d1129f3d19
4 changed files with 25 additions and 2 deletions

View File

@ -1,2 +1,3 @@
idf_component_register(INCLUDE_DIRS include
idf_component_register(SRCS "esp_err_to_name.c"
INCLUDE_DIRS include
REQUIRES esp_netif_linux esp_event_mock)

View File

@ -0,0 +1,14 @@
/*
* SPDX-FileCopyrightText: Franz Hoepfinger
*
* SPDX-License-Identifier: Apache-2.0
*/
static const char esp_unknown_msg[] = "ERROR";
const char *esp_err_to_name(int code)
{
return esp_unknown_msg;
}

View File

@ -25,3 +25,11 @@ typedef int esp_err_t;
#define ESP_ERR_NOT_FOUND 0x105
#define ESP_ERR_NOT_SUPPORTED 0x106
#define ESP_ERR_TIMEOUT 0x107
#ifdef __cplusplus
extern "C" {
#endif
const char *esp_err_to_name(int code);
#ifdef __cplusplus
}
#endif

View File

@ -22,7 +22,7 @@
action; \
} catch (::esp_modem::esp_err_exception& e) { \
esp_err_t err = e.get_err_t(); \
ESP_LOGE(TAG, "%s: Exception caught with ESP err_code=%d", __func__, err); \
ESP_LOGE(TAG, "%s: Exception caught with ESP err_code=%d %s", __func__, err, esp_err_to_name(err)); \
ESP_LOGE(TAG, "%s", e.what()); \
action; \
}