Re: [asio-users] asio and good error handling
Brought to you by:
chris_kohlhoff
From: Dmitrij V <dm...@gm...> - 2018-12-27 21:32:42
|
There are two ways to handle the errors. 1) exceptions: try { /* ... */ } catch (const asio::error_code &ec) { std::cerr << "error: " << ec.message() << std::endl; } 2) and by place: error_code ec; asio::read(sock, buff, ec); if (ec) std::cerr << "error: " << ec.message() << std::endl; If you want detailed error reporting - see class error_code (header <asio/error_code.hpp>) and its methods like: value(), category() ... PS: For me enough string by error_code::message() (for logs)... -- the best regards |