Files
esp-protocols/esp_modem/private_include/exception_stub.hpp
2021-10-04 11:32:54 +02:00

27 lines
671 B
C++

//
// Created by david on 3/16/21.
//
#ifndef MODEM_CONSOLE_EXCEPTION_STUB_HPP
#define MODEM_CONSOLE_EXCEPTION_STUB_HPP
#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
#define TRY_CATCH_RET_NULL(block) \
try { block \
} catch (std::bad_alloc& e) { \
ESP_LOGE(TAG, "Out of memory"); \
return nullptr; \
} catch (esp_err_exception& e) { \
esp_err_t err = e.get_err_t(); \
ESP_LOGE(TAG, "Error occurred during UART term init: %d", err); \
ESP_LOGE(TAG, "%s", e.what()); \
return nullptr; \
}
#else
#define TRY_CATCH_RET_NULL(block) \
block
#endif
#endif //MODEM_CONSOLE_EXCEPTION_STUB_HPP