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,11 +16,17 @@ namespace glib::impl
const char *ptr = nullptr;
try
{
ptr = wsview_to_char(e.message());
const auto wmsg = std::wstring_view{e.message()};
if (not wmsg.empty())
{
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 (...)
{
g_free(const_cast<char *>(ptr));