增加获取模块加载错误信息

This commit is contained in:
xx
2024-06-11 15:02:01 +08:00
parent 9f2f6362ee
commit 46c3faeaa7

View File

@@ -33,6 +33,7 @@ fastweb::module_manager::~module_manager()
}
void fastweb::module_manager::start()
{
#ifdef _WIN32
auto get_last_error_desc = []()->std::string {
DWORD dwError = GetLastError();
// 获取错误描述
@@ -51,6 +52,7 @@ void fastweb::module_manager::start()
// 输出错误描述
return std::string(lpMsgBuf);
};
#endif
close();
auto ms = modules();
for (size_t i = 0; i < ms.size(); i++)
@@ -62,7 +64,11 @@ void fastweb::module_manager::start()
mi.dll = LoadLibrary(mod_filepath.c_str());
if (mi.dll == nullptr)
{
LOG_ERROR("module loading failed, filename: " + mod_filepath+","+ codec::to_utf8(get_last_error_desc()));
LOG_ERROR("module loading failed, filename: " + mod_filepath
#ifdef _WIN32
+","+ codec::to_utf8(get_last_error_desc())
#endif
);
continue;
}
mi.func = (fastweb_module_regist)GetProcAddress((HMODULE)mi.dll, "fastweb_module_regist");