24#include <boost/system/system_error.hpp>
88 const char*
what()
const noexcept override;
127template<
typename Func,
typename Ret>
154 *ret = func(&our_err_code);
167template<
typename Func>
202#define FLOW_ERROR_EMIT_ERROR(ARG_val) \
203 FLOW_UTIL_SEMICOLON_SAFE \
205 ::flow::Error_code FLOW_ERROR_EMIT_ERR_val(ARG_val); \
206 FLOW_LOG_WARNING("Error code emitted: [" << FLOW_ERROR_EMIT_ERR_val << "] " \
207 "[" << FLOW_ERROR_EMIT_ERR_val.message() << "]."); \
208 *err_code = FLOW_ERROR_EMIT_ERR_val; \
218#define FLOW_ERROR_EMIT_ERROR_LOG_INFO(ARG_val) \
219 FLOW_UTIL_SEMICOLON_SAFE \
221 ::flow::Error_code FLOW_ERROR_EMIT_ERR_LOG_val(ARG_val); \
222 FLOW_LOG_INFO("Error code emitted: [" << FLOW_ERROR_EMIT_ERR_LOG_val << "] " \
223 "[" << FLOW_ERROR_EMIT_ERR_LOG_val.message() << "]."); \
224 *err_code = FLOW_ERROR_EMIT_ERR_LOG_val; \
233#define FLOW_ERROR_LOG_ERROR(ARG_val) \
234 FLOW_UTIL_SEMICOLON_SAFE \
236 ::flow::Error_code FLOW_ERROR_LOG_ERR_val(ARG_val); \
237 FLOW_LOG_WARNING("Error occurred: [" << FLOW_ERROR_LOG_ERR_val << "] " \
238 "[" << FLOW_ERROR_LOG_ERR_val.message() << "]."); \
269#define FLOW_ERROR_SYS_ERROR_LOG_WARNING() \
270 FLOW_LOG_WARNING("System error occurred: [" << sys_err_code << "] [" << sys_err_code.message() << "].")
302#define FLOW_ERROR_SYS_ERROR_LOG_FATAL() \
303 FLOW_LOG_FATAL("System error occurred: [" << sys_err_code << "] [" << sys_err_code.message() << "].")
357#define FLOW_ERROR_EXEC_AND_THROW_ON_ERROR(ARG_ret_type, ARG_method_name, ...) \
358 FLOW_ERROR_EXEC_FUNC_AND_THROW_ON_ERROR(ARG_ret_type, ARG_method_name, this, __VA_ARGS__)
404#define FLOW_ERROR_EXEC_FUNC_AND_THROW_ON_ERROR(ARG_ret_type, ARG_function_name, ...) \
405 FLOW_UTIL_SEMICOLON_SAFE \
407 using namespace boost::placeholders; \
412 ARG_ret_type result; \
416 if (::flow::error::exec_and_throw_on_error(::flow::util::bind_ns::bind(&ARG_function_name, __VA_ARGS__), \
419 FLOW_UTIL_WHERE_AM_I_LITERAL(ARG_function_name))) \
An std::runtime_error (which is an std::exception) that stores an Error_code.
Runtime_error(const Error_code &err_code_or_success, util::String_view context="")
Constructs Runtime_error.
const std::string m_context_if_no_code
This is a copy of context from ctor if !err_code_or_success; or unused otherwise.
const char * what() const noexcept override
Returns a message describing the exception.
Flow module that facilitates working with error codes and exceptions; essentially comprised of niceti...
bool exec_void_and_throw_on_error(const Func &func, Error_code *err_code, util::String_view context)
Equivalent of exec_and_throw_on_error() for operations with void return type.
bool exec_and_throw_on_error(const Func &func, Ret *ret, Error_code *err_code, util::String_view context)
Helper for FLOW_ERROR_EXEC_AND_THROW_ON_ERROR() macro that does everything in the latter not needing ...
Basic_string_view< char > String_view
Commonly used char-based Basic_string_view. See its doc header.
boost::system::error_code Error_code
Short-hand for a boost.system error code (which basically encapsulates an integer/enum error code and...