handle empty hresult_error message specially
This commit is contained in:
parent
c44b1daaf7
commit
ab6ce05aec
|
@ -16,11 +16,17 @@ 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()};
|
||||||
|
if (not wmsg.empty())
|
||||||
|
{
|
||||||
|
ptr = wsview_to_char(wmsg);
|
||||||
std::string msg{ptr};
|
std::string msg{ptr};
|
||||||
g_free(const_cast<char *>(ptr)); // WTF? Deletion is not modification!
|
g_free(const_cast<char *>(ptr)); // WTF? Deletion is not modification!
|
||||||
return {{ e.code(), {std::move(msg)} }};
|
return {{ e.code(), {std::move(msg)} }};
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return {{ e.code(), {"<no error description>"} }};
|
||||||
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
g_free(const_cast<char *>(ptr));
|
g_free(const_cast<char *>(ptr));
|
||||||
|
|
Loading…
Reference in a new issue