diff --git a/src/libimp/platform/win/system.h b/src/libimp/platform/win/system.h index 58dbda8..d8a199d 100644 --- a/src/libimp/platform/win/system.h +++ b/src/libimp/platform/win/system.h @@ -15,6 +15,7 @@ #include "libimp/log.h" #include "libimp/codecvt.h" #include "libimp/enum_cast.h" +#include "libimp/detect_plat.h" LIBIMP_NAMESPACE_BEG_ namespace sys { @@ -46,7 +47,7 @@ void error_code(result_code code) noexcept { */ std::string error_str(result_code code) noexcept { LIBIMP_LOG_(); - try { + LIBIMP_TRY { DWORD err = (DWORD)code.value(); LPTSTR lpErrText = NULL; if (::FormatMessage( @@ -73,7 +74,7 @@ std::string error_str(result_code code) noexcept { std::string ret(len, '\0'); cvt_cstr(lpErrText, msg_len, &ret[0], ret.size()); return ret; - } catch (std::exception const &e) { + } LIBIMP_CATCH(std::exception const &e) { log.failed(e.what()); } return {}; diff --git a/src/libimp/system.cpp b/src/libimp/system.cpp index 958d2cd..2c1296b 100644 --- a/src/libimp/system.cpp +++ b/src/libimp/system.cpp @@ -11,9 +11,9 @@ LIBIMP_NAMESPACE_BEG_ namespace sys { std::string error_msg(result_code code) noexcept { - try { + LIBIMP_TRY { return ::fmt::format("[{}, \"{}\"]", code.value(), error_str(code)); - } catch (...) { + } LIBIMP_CATCH(...) { return error_str(code); } }