Boost error codes human-readable description

2019-04-04 03:25发布

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条回答
该账号已被封号
2楼-- · 2019-04-04 03:52

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.

查看更多
登录 后发表回答