Boost error codes human-readable description

后端 未结 1 1942
不思量自难忘°
不思量自难忘° 2021-02-18 23:11

I\'m catching errors in Boost Asio program like

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


        
1条回答
  •  爱一瞬间的悲伤
    2021-02-18 23:35

    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.

    0 讨论(0)
提交回复
热议问题