diff --git a/lib/asio_client_session_impl.cc b/lib/asio_client_session_impl.cc index b96824d..f184cff 100644 --- a/lib/asio_client_session_impl.cc +++ b/lib/asio_client_session_impl.cc @@ -483,7 +483,7 @@ const request *session_impl::submit(boost::system::error_code &ec, ec.clear(); if (stopped_) { - ec = make_error_code(static_cast(NGHTTP2_INTERNAL_ERROR)); + ec = make_error_code(static_cast(NGHTTP2_INTERNAL_ERROR)); return nullptr; } diff --git a/lib/asio_common.cc b/lib/asio_common.cc index 428dbd6..8c0a4eb 100644 --- a/lib/asio_common.cc +++ b/lib/asio_common.cc @@ -74,6 +74,22 @@ boost::system::error_code make_error_code(nghttp2_asio_error ev) { nghttp2_asio_category()); } +class nghttp2_error_code_category_impl : public boost::system::error_category { + public: + const char *name() const noexcept { return "nghttp2_error_code"; } + std::string message(int ev) const noexcept { return nghttp2_http2_strerror(ev); } +}; + +const boost::system::error_category &nghttp2_error_code_category() noexcept { + static nghttp2_error_code_category_impl cat; + return cat; +} + +boost::system::error_code make_error_code(nghttp2_error_code ev){ + return boost::system::error_code(static_cast(ev), + nghttp2_error_code_category()); +} + generator_cb string_generator(std::string data) { auto strio = std::make_shared>(std::move(data), data.size()); diff --git a/lib/asio_common.h b/lib/asio_common.h index 7eacfa5..2514234 100644 --- a/lib/asio_common.h +++ b/lib/asio_common.h @@ -41,6 +41,8 @@ boost::system::error_code make_error_code(nghttp2_error ev); boost::system::error_code make_error_code(nghttp2_asio_error ev); +boost::system::error_code make_error_code(nghttp2_error_code ev); + generator_cb string_generator(std::string data); // Returns generator_cb, which just returns NGHTTP2_ERR_DEFERRED