From 85e83643feef4dc955dc6372fcd5b92fc380582d Mon Sep 17 00:00:00 2001 From: Alex Fabijanic Date: Wed, 9 Sep 2020 15:46:42 +0200 Subject: [PATCH] feat(SharedLibrary): add more detailed error description when LoadLibrary fails --- Foundation/src/SharedLibrary_WIN32U.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Foundation/src/SharedLibrary_WIN32U.cpp b/Foundation/src/SharedLibrary_WIN32U.cpp index b4f697ea0..5fd6880ea 100644 --- a/Foundation/src/SharedLibrary_WIN32U.cpp +++ b/Foundation/src/SharedLibrary_WIN32U.cpp @@ -16,6 +16,9 @@ #include "Poco/UnicodeConverter.h" #include "Poco/Path.h" #include "Poco/UnWindows.h" +#include "Poco/Error.h" +#include "Poco/Format.h" +#include "Poco/String.h" namespace Poco { @@ -48,7 +51,13 @@ void SharedLibraryImpl::loadImpl(const std::string& path, int /*flags*/) std::wstring upath; UnicodeConverter::toUTF16(path, upath); _handle = LoadLibraryExW(upath.c_str(), 0, flags); - if (!_handle) throw LibraryLoadException(path); + if (!_handle) + { + int errn = static_cast(Error::last()); + std::string err; + Poco::format(err, "Error %d while loading [%s]: [%s]", errn, path, Poco::trim(Error::getMessage(errn))); + throw LibraryLoadException(err); + } _path = path; }