Loading media/liberror/include/error/expected_utils.h +41 −15 Original line number Diff line number Diff line Loading @@ -20,6 +20,10 @@ #include <android-base/expected.h> #include <log/log_main.h> #pragma push_macro("LOG_TAG") #undef LOG_TAG #define LOG_TAG "MediaLibError" /** * Useful macros for working with status codes and base::expected. * Loading Loading @@ -53,14 +57,22 @@ #define VALUE_OR_RETURN(exp) \ ({ \ auto _tmp = (exp); \ if (!_tmp.ok()) return ::android::base::unexpected(std::move(_tmp.error())); \ if (!_tmp.ok()) { \ ALOGE("Function: %s Line: %d Failed result (%s)", __FUNCTION__, __LINE__, \ errorToString(_tmp.error()).c_str()); \ return ::android::base::unexpected(std::move(_tmp.error())); \ } \ std::move(_tmp.value()); \ }) #define VALUE_OR_RETURN_STATUS(exp) \ ({ \ auto _tmp = (exp); \ if (!_tmp.ok()) return std::move(_tmp.error()); \ if (!_tmp.ok()) { \ ALOGE("Function: %s Line: %d Failed result (%s)", __FUNCTION__, __LINE__, \ errorToString(_tmp.error()).c_str()); \ return std::move(_tmp.error()); \ } \ std::move(_tmp.value()); \ }) Loading @@ -73,10 +85,22 @@ }) #define RETURN_IF_ERROR(exp) \ if (auto _tmp = (exp); !errorIsOk(_tmp)) return ::android::base::unexpected(std::move(_tmp)); ({ \ auto _tmp = (exp); \ if (!errorIsOk(_tmp)) { \ ALOGE("Function: %s Line: %d Failed ", __FUNCTION__, __LINE__); \ return ::android::base::unexpected(std::move(_tmp)); \ } \ }) #define RETURN_STATUS_IF_ERROR(exp) \ if (auto _tmp = (exp); !errorIsOk(_tmp)) return _tmp; ({ \ auto _tmp = (exp); \ if (!errorIsOk(_tmp)) { \ ALOGE("Function: %s Line: %d Failed ", __FUNCTION__, __LINE__); \ return _tmp; \ } \ }) #define FATAL_IF_ERROR(exp) \ { \ Loading @@ -84,3 +108,5 @@ LOG_ALWAYS_FATAL_IF(!errorIsOk(_tmp), "Function: %s Line: %d Failed result: (%s)", \ __FUNCTION__, __LINE__, errorToString(_tmp).c_str()); \ } #pragma pop_macro("LOG_TAG") Loading
media/liberror/include/error/expected_utils.h +41 −15 Original line number Diff line number Diff line Loading @@ -20,6 +20,10 @@ #include <android-base/expected.h> #include <log/log_main.h> #pragma push_macro("LOG_TAG") #undef LOG_TAG #define LOG_TAG "MediaLibError" /** * Useful macros for working with status codes and base::expected. * Loading Loading @@ -53,14 +57,22 @@ #define VALUE_OR_RETURN(exp) \ ({ \ auto _tmp = (exp); \ if (!_tmp.ok()) return ::android::base::unexpected(std::move(_tmp.error())); \ if (!_tmp.ok()) { \ ALOGE("Function: %s Line: %d Failed result (%s)", __FUNCTION__, __LINE__, \ errorToString(_tmp.error()).c_str()); \ return ::android::base::unexpected(std::move(_tmp.error())); \ } \ std::move(_tmp.value()); \ }) #define VALUE_OR_RETURN_STATUS(exp) \ ({ \ auto _tmp = (exp); \ if (!_tmp.ok()) return std::move(_tmp.error()); \ if (!_tmp.ok()) { \ ALOGE("Function: %s Line: %d Failed result (%s)", __FUNCTION__, __LINE__, \ errorToString(_tmp.error()).c_str()); \ return std::move(_tmp.error()); \ } \ std::move(_tmp.value()); \ }) Loading @@ -73,10 +85,22 @@ }) #define RETURN_IF_ERROR(exp) \ if (auto _tmp = (exp); !errorIsOk(_tmp)) return ::android::base::unexpected(std::move(_tmp)); ({ \ auto _tmp = (exp); \ if (!errorIsOk(_tmp)) { \ ALOGE("Function: %s Line: %d Failed ", __FUNCTION__, __LINE__); \ return ::android::base::unexpected(std::move(_tmp)); \ } \ }) #define RETURN_STATUS_IF_ERROR(exp) \ if (auto _tmp = (exp); !errorIsOk(_tmp)) return _tmp; ({ \ auto _tmp = (exp); \ if (!errorIsOk(_tmp)) { \ ALOGE("Function: %s Line: %d Failed ", __FUNCTION__, __LINE__); \ return _tmp; \ } \ }) #define FATAL_IF_ERROR(exp) \ { \ Loading @@ -84,3 +108,5 @@ LOG_ALWAYS_FATAL_IF(!errorIsOk(_tmp), "Function: %s Line: %d Failed result: (%s)", \ __FUNCTION__, __LINE__, errorToString(_tmp).c_str()); \ } #pragma pop_macro("LOG_TAG")