asio: Use boost::system::error_code for on_error callback

This commit is contained in:
Tatsuhiro Tsujikawa 2015-03-04 00:23:17 +09:00
parent 8afd75ca47
commit b2196f215a
3 changed files with 5 additions and 5 deletions

View File

@ -103,8 +103,8 @@ int main(int argc, char *argv[]) {
}); });
}); });
sess.on_error([](const std::string &error) { sess.on_error([](const boost::system::error_code &ec) {
std::cerr << "error: " << error << std::endl; std::cerr << "error: " << ec.message() << std::endl;
}); });
io_service.run(); io_service.run();

View File

@ -91,7 +91,7 @@ void session_impl::connected() {
void session_impl::not_connected(const boost::system::error_code &ec) { void session_impl::not_connected(const boost::system::error_code &ec) {
auto &error_cb = on_error(); auto &error_cb = on_error();
if (error_cb) { if (error_cb) {
error_cb(ec.message()); error_cb(ec);
} }
} }
@ -307,7 +307,7 @@ bool session_impl::setup_session() {
if (rv != 0) { if (rv != 0) {
auto &error_cb = on_error(); auto &error_cb = on_error();
if (error_cb) { if (error_cb) {
error_cb(nghttp2_strerror(rv)); error_cb(make_error_code(static_cast<nghttp2_error>(rv)));
} }
return false; return false;
} }

View File

@ -76,7 +76,7 @@ const boost::system::error_category &nghttp2_category() noexcept;
typedef std::function<void(const uint8_t *, std::size_t)> data_cb; typedef std::function<void(const uint8_t *, std::size_t)> data_cb;
typedef std::function<void(void)> void_cb; typedef std::function<void(void)> void_cb;
typedef std::function<void(const std::string &err)> error_cb; typedef std::function<void(const boost::system::error_code &ec)> error_cb;
typedef std::function<void(uint32_t)> close_cb; typedef std::function<void(uint32_t)> close_cb;
// Callback function to generate response body. The implementation of // Callback function to generate response body. The implementation of