Boost error codes human-readable description

巧了我就是萌 提交于 2019-12-12 08:19:36

问题


I'm catching errors in Boost Asio program like

if (!error)
{
    //do stuff
}
else
{
    std::cout << "Error : " << error << std::endl;
    //handle error
}

But the error isn't human-readable (e.g. connecting to SSL server without certificate gives error asio.ssl:335544539). Is there any better way how to display error ?


回答1:


If you are likely using boost::system::error_code you can call:

error.message()

to get a more human-friendly message.

Using operator<< translates into:

os << ec.category().name() << ':' << ec.value()

Here you can check a detailed overview of the available members in error_code.



来源:https://stackoverflow.com/questions/10755084/boost-error-codes-human-readable-description

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!