handle empty hresult_error message specially

This commit is contained in:
mjk 2021-03-19 22:44:38 +00:00 committed by LAGonauta
parent c44b1daaf7
commit ab6ce05aec

View file

@ -16,10 +16,16 @@ namespace glib::impl
const char *ptr = nullptr; const char *ptr = nullptr;
try try
{ {
ptr = wsview_to_char(e.message()); const auto wmsg = std::wstring_view{e.message()};
std::string msg{ptr}; if (not wmsg.empty())
g_free(const_cast<char *>(ptr)); // WTF? Deletion is not modification! {
return {{ e.code(), {std::move(msg)} }}; ptr = wsview_to_char(wmsg);
std::string msg{ptr};
g_free(const_cast<char *>(ptr)); // WTF? Deletion is not modification!
return {{ e.code(), {std::move(msg)} }};
}
else
return {{ e.code(), {"<no error description>"} }};
} }
catch (...) catch (...)
{ {