mirror of
https://github.com/microsoft/krabsetw
synced 2026-06-06 16:14:32 +00:00
Suppress wchar_t to char narrowing when constructing error messages (#115)
This commit is contained in:
@@ -59,7 +59,10 @@ namespace krabs {
|
||||
{
|
||||
HRESULT hr = CLSIDFromString(guid.c_str(), &guid_);
|
||||
if (FAILED(hr)) {
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4244) // narrowing guid wchar_t to char for this error message
|
||||
std::string guidStr(guid.begin(), guid.end());
|
||||
#pragma warning(pop)
|
||||
std::stringstream stream;
|
||||
stream << "Error in constructing guid from string (";
|
||||
stream << guidStr;
|
||||
|
||||
@@ -101,7 +101,10 @@ namespace krabs {
|
||||
|
||||
if (requested == actual) return;
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4244) // narrowing property name wchar_t to char for this error message
|
||||
std::string ansiName(name.begin(), name.end());
|
||||
#pragma warning(pop)
|
||||
|
||||
throw type_mismatch_assert(
|
||||
ansiName.c_str(),
|
||||
|
||||
@@ -233,8 +233,12 @@ namespace krabs { namespace testing {
|
||||
if (!results.second.empty()) {
|
||||
std::string msg = "Not all the properties of the event were filled:";
|
||||
|
||||
for (auto& s : results.second)
|
||||
for (auto& s : results.second) {
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4244) // narrowing property name wchar_t to char for this error message
|
||||
msg += " " + std::string(s.begin(), s.end());
|
||||
#pragma warning(pop)
|
||||
}
|
||||
|
||||
throw std::invalid_argument(msg);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user