Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boost error codes human-readable description

Tags:

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 ?

like image 354
user1307957 Avatar asked May 25 '12 13:05

user1307957


1 Answers

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.

like image 66
betabandido Avatar answered Oct 20 '22 23:10

betabandido