Suppress wchar_t to char narrowing when constructing error messages (#115)

This commit is contained in:
Matt Swann
2020-03-24 09:18:08 -07:00
committed by GitHub
parent 75a5be3406
commit 7ae868c9c1
3 changed files with 11 additions and 1 deletions
+3
View File
@@ -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;
+3
View File
@@ -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(),
+5 -1
View File
@@ -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);
}