diff --git a/doc/modules/ROOT/pages/3.messages/3b.serializing.adoc b/doc/modules/ROOT/pages/3.messages/3b.serializing.adoc index 73cf843a..97bbeb29 100644 --- a/doc/modules/ROOT/pages/3.messages/3b.serializing.adoc +++ b/doc/modules/ROOT/pages/3.messages/3b.serializing.adoc @@ -36,7 +36,7 @@ while (!sr.is_done()) { auto result = sr.prepare(); if (!result) - throw system::system_error(result.error()); + throw std::system_error(result.error()); co_await socket.write(*result); sr.consume(capy::buffer_size(*result)); @@ -260,7 +260,7 @@ while (!sr.is_done()) } if (!result) - throw system::system_error(result.error()); + throw std::system_error(result.error()); co_await socket.write(*result); sr.consume(capy::buffer_size(*result)); diff --git a/doc/modules/ROOT/pages/3.messages/3c.parsing.adoc b/doc/modules/ROOT/pages/3.messages/3c.parsing.adoc index 85d8f659..3fc8075a 100644 --- a/doc/modules/ROOT/pages/3.messages/3c.parsing.adoc +++ b/doc/modules/ROOT/pages/3.messages/3c.parsing.adoc @@ -58,7 +58,7 @@ auto buf = pr.prepare(); std::size_t n = socket.read_some(buf); pr.commit(n); -system::error_code ec; +std::error_code ec; pr.parse(ec); // 6. Check result @@ -120,11 +120,11 @@ while (!pr.got_header()) std::size_t n = socket.read_some(buf); pr.commit(n); - system::error_code ec; + std::error_code ec; pr.parse(ec); if (ec && ec != condition::need_more_input) - throw system::system_error(ec); + throw std::system_error(ec); } // Access the parsed request @@ -152,10 +152,10 @@ while (!pr.is_complete()) std::size_t n = socket.read_some(buf); pr.commit(n); - system::error_code ec; + std::error_code ec; pr.parse(ec); if (ec && ec != condition::need_more_input) - throw system::system_error(ec); + throw std::system_error(ec); } // Access the complete body @@ -176,10 +176,10 @@ while (!pr.is_complete()) std::size_t n = socket.read_some(buf); pr.commit(n); - system::error_code ec; + std::error_code ec; pr.parse(ec); if (ec && ec != condition::need_more_input) - throw system::system_error(ec); + throw std::system_error(ec); // Process available body data auto body_bufs = pr.pull_body(); @@ -252,13 +252,13 @@ while (connection_open) } pr.commit(n); - system::error_code ec; + std::error_code ec; pr.parse(ec); if (ec == error::end_of_stream) break; // Clean connection close if (ec && ec != condition::need_more_input) - throw system::system_error(ec); + throw std::system_error(ec); } // Process the request @@ -268,11 +268,11 @@ while (connection_open) == Error Handling -The parser reports errors through `system::error_code`: +The parser reports errors through `std::error_code`: [source,cpp] ---- -system::error_code ec; +std::error_code ec; pr.parse(ec); if (ec == condition::need_more_input) diff --git a/doc/modules/ROOT/pages/4.servers/4b.route-handlers.adoc b/doc/modules/ROOT/pages/4.servers/4b.route-handlers.adoc index 3c6ae545..010e639f 100644 --- a/doc/modules/ROOT/pages/4.servers/4b.route-handlers.adoc +++ b/doc/modules/ROOT/pages/4.servers/4b.route-handlers.adoc @@ -111,7 +111,7 @@ And for errors: [source,cpp] ---- -co_return route_error(ec); // from a system::error_code +co_return route_error(ec); // from a std::error_code ---- These five outcomes cover every situation a handler can encounter. Most @@ -620,7 +620,7 @@ takes two parameters: ---- route_task my_error_handler( route_params& rp, - system::error_code ec) + std::error_code ec) { rp.status(status::internal_server_error); rp.res.set(field::content_type, "text/plain"); @@ -641,7 +641,7 @@ router.use(my_error_handler); // Error handler scoped to /api routes router.use("/api", - [](route_params& rp, system::error_code ec) + [](route_params& rp, std::error_code ec) -> route_task { rp.status(status::internal_server_error); @@ -655,7 +655,7 @@ router.use("/api", The router distinguishes regular handlers from error handlers by inspecting their signature at compile time. A callable that accepts `(route_params&)` is a regular handler. A callable that accepts -`(route_params&, system::error_code)` is an error handler. They +`(route_params&, std::error_code)` is an error handler. They can coexist in the same `use()` call. === Error Propagation @@ -669,7 +669,7 @@ processing: ---- // Log the error, then pass it along router.use( - [](route_params& rp, system::error_code ec) + [](route_params& rp, std::error_code ec) -> route_task { std::cerr << "Error: " << ec.message() << "\n"; @@ -678,7 +678,7 @@ router.use( // Send a user-facing response router.use( - [](route_params& rp, system::error_code ec) + [](route_params& rp, std::error_code ec) -> route_task { rp.status(status::internal_server_error); @@ -700,7 +700,7 @@ web frontend returns HTML: [source,cpp] ---- router.use("/api", - [](route_params& rp, system::error_code ec) + [](route_params& rp, std::error_code ec) -> route_task { rp.status(status::internal_server_error); @@ -711,7 +711,7 @@ router.use("/api", }); router.use( - [](route_params& rp, system::error_code ec) + [](route_params& rp, std::error_code ec) -> route_task { rp.status(status::internal_server_error); diff --git a/doc/modules/ROOT/pages/4.servers/4c.routers.adoc b/doc/modules/ROOT/pages/4.servers/4c.routers.adoc index 3e56bbe1..63cb8d27 100644 --- a/doc/modules/ROOT/pages/4.servers/4c.routers.adoc +++ b/doc/modules/ROOT/pages/4.servers/4c.routers.adoc @@ -556,7 +556,7 @@ api.add(method::get, "/fragile", router<> app; app.use("/api", std::move(api)); app.use( - [](route_params& rp, system::error_code ec) -> route_task + [](route_params& rp, std::error_code ec) -> route_task { rp.status(status::internal_server_error); co_await rp.send("Error: " + ec.message()); @@ -771,7 +771,7 @@ An error handler is a callable with a specific signature: ---- route_task handle_error( route_params& rp, - system::error_code ec) + std::error_code ec) { rp.status(status::internal_server_error); co_await rp.send("Error: " + ec.message()); @@ -781,7 +781,7 @@ route_task handle_error( The router distinguishes error handlers from regular handlers at compile time by inspecting the callable's parameter list. A callable -that accepts `(route_params&, system::error_code)` is automatically +that accepts `(route_params&, std::error_code)` is automatically treated as an error handler. No special registration method is needed -- you install them with the same `use()` that registers middleware: @@ -808,7 +808,7 @@ An error handler can: ---- // Log the error, then pass it along r.use( - [](route_params& rp, system::error_code ec) + [](route_params& rp, std::error_code ec) -> route_task { std::cerr << "Error: " << ec.message() << "\n"; @@ -817,7 +817,7 @@ r.use( // Send a response to the client r.use( - [](route_params& rp, system::error_code ec) + [](route_params& rp, std::error_code ec) -> route_task { rp.status(status::internal_server_error); @@ -837,7 +837,7 @@ while the rest of the application returns HTML: [source,cpp] ---- r.use("/api", - [](route_params& rp, system::error_code ec) + [](route_params& rp, std::error_code ec) -> route_task { rp.status(status::internal_server_error); @@ -848,7 +848,7 @@ r.use("/api", }); r.use( - [](route_params& rp, system::error_code ec) + [](route_params& rp, std::error_code ec) -> route_task { rp.status(status::internal_server_error); @@ -1136,7 +1136,7 @@ app.use(serve_static("/var/www/public")); // Global error handler app.use( - [](route_params& rp, system::error_code ec) + [](route_params& rp, std::error_code ec) -> route_task { rp.status(status::internal_server_error); diff --git a/doc/modules/ROOT/pages/4.servers/4g.bcrypt.adoc b/doc/modules/ROOT/pages/4.servers/4g.bcrypt.adoc index fe10b7f9..e6675d96 100644 --- a/doc/modules/ROOT/pages/4.servers/4g.bcrypt.adoc +++ b/doc/modules/ROOT/pages/4.servers/4g.bcrypt.adoc @@ -36,7 +36,7 @@ bcrypt::result hash = bcrypt::hash("my_password", 12); // Store hash.str() in database... // Later, verify the password -system::error_code ec; +std::error_code ec; bool valid = bcrypt::compare("my_password", stored_hash, ec); if (ec) @@ -112,7 +112,7 @@ the input password, and compares: [source,cpp] ---- -system::error_code ec; +std::error_code ec; bool valid = bcrypt::compare(user_input, stored_hash, ec); if (ec == bcrypt::error::invalid_hash) @@ -141,7 +141,7 @@ You can generate and use salts separately: bcrypt::result salt = bcrypt::gen_salt(12); // Hash with explicit salt -system::error_code ec; +std::error_code ec; bcrypt::result hash = bcrypt::hash("password", salt.str(), ec); ---- @@ -185,7 +185,7 @@ To check the cost factor of an existing hash: [source,cpp] ---- -system::error_code ec; +std::error_code ec; unsigned rounds = bcrypt::get_rounds(stored_hash, ec); if (ec) @@ -200,7 +200,7 @@ When a user logs in successfully, you can check if their hash needs upgrading: [source,cpp] ---- -system::error_code ec; +std::error_code ec; bool valid = bcrypt::compare(password, stored_hash, ec); if (valid && !ec) diff --git a/doc/modules/ROOT/pages/5.compression/5c.zstd.adoc b/doc/modules/ROOT/pages/5.compression/5c.zstd.adoc index 06c0181e..dceef400 100644 --- a/doc/modules/ROOT/pages/5.compression/5c.zstd.adoc +++ b/doc/modules/ROOT/pages/5.compression/5c.zstd.adoc @@ -36,14 +36,14 @@ with `is_error` before using it: std::size_t n = compressor.compress(/* ... */); if (compressor.is_error(n)) { - boost::system::error_code ec = compressor.get_error_code(n); + std::error_code ec = compressor.get_error_code(n); std::cerr << compressor.get_error_name(n) << '\n'; return ec; } ---- -`zstd::error` is a Boost.System error enum, so an error code converts to -`boost::system::error_code` and `std::error_code`. +`zstd::error` is a standard error enum, so an error code converts to +`std::error_code` and `std::error_code`. === One-Shot Compression diff --git a/doc/modules/ROOT/pages/6.design/6a.sans-io.adoc b/doc/modules/ROOT/pages/6.design/6a.sans-io.adoc index 7e2bc0cb..191ab85c 100644 --- a/doc/modules/ROOT/pages/6.design/6a.sans-io.adoc +++ b/doc/modules/ROOT/pages/6.design/6a.sans-io.adoc @@ -94,9 +94,9 @@ while (! in.empty()) } pr.commit_eof(); -system::error_code ec; +std::error_code ec; pr.parse(ec); -BOOST_TEST(! ec.failed()); +BOOST_TEST(! ec); BOOST_TEST(pr.is_complete()); BOOST_TEST_EQ(pr.get().status(), status::ok); ---- diff --git a/doc/modules/ROOT/pages/6.design/6b.parser.adoc b/doc/modules/ROOT/pages/6.design/6b.parser.adoc index 16698972..042bf236 100644 --- a/doc/modules/ROOT/pages/6.design/6b.parser.adoc +++ b/doc/modules/ROOT/pages/6.design/6b.parser.adoc @@ -141,7 +141,7 @@ read_some(stream& s, parser& pr, error_code& ec) pr.commit_eof(); ec = {}; } - else if(ec.failed()) + else if(ec) { return; } @@ -158,8 +158,8 @@ read_header(stream& s, parser& pr) read_some(s, pr, ec); if(ec == condition::need_more_input) continue; - if(ec.failed()) - throw system::system_error(ec); + if(ec) + throw std::system_error(ec); } while(! pr.got_header()); } @@ -173,8 +173,8 @@ read(stream& s, parser& pr) read_some(s, pr, ec); if(ec == condition::need_more_input) continue; - if(ec.failed()) - throw system::system_error(ec); + if(ec) + throw std::system_error(ec); } while(! pr.is_complete()); } diff --git a/include/boost/http/bcrypt.hpp b/include/boost/http/bcrypt.hpp index 47f3eb59..dd387798 100644 --- a/include/boost/http/bcrypt.hpp +++ b/include/boost/http/bcrypt.hpp @@ -15,7 +15,7 @@ **Tier 1 -- Synchronous** (low-level, no capy dependency): @code bcrypt::result r = bcrypt::hash("password", 12); - system::error_code ec; + std::error_code ec; bool ok = bcrypt::compare("password", r.str(), ec); @endcode @@ -37,9 +37,6 @@ #include #include #include -#include -#include -#include #include #include @@ -95,14 +92,6 @@ enum class error } // bcrypt } // http -namespace system { -template<> -struct is_error_code_enum< - ::boost::http::bcrypt::error> -{ - static bool const value = true; -}; -} // system } // boost namespace std { @@ -120,19 +109,13 @@ namespace detail { struct BOOST_SYMBOL_VISIBLE error_cat_type - : system::error_category + : std::error_category { BOOST_HTTP_DECL const char* name( ) const noexcept override; BOOST_HTTP_DECL std::string message( int) const override; - BOOST_HTTP_DECL char const* message( - int, char*, std::size_t - ) const noexcept override; - BOOST_SYSTEM_CONSTEXPR error_cat_type() - : error_category(0xbc8f2a4e7c193d56) - { - } + constexpr error_cat_type() noexcept = default; }; BOOST_HTTP_DECL extern @@ -141,12 +124,11 @@ BOOST_HTTP_DECL extern } // detail inline -BOOST_SYSTEM_CONSTEXPR -system::error_code +std::error_code make_error_code( error ev) noexcept { - return system::error_code{ + return std::error_code{ static_cast::type>(ev), detail::error_cat}; @@ -240,7 +222,7 @@ class result private: friend BOOST_HTTP_DECL result gen_salt(unsigned, version); friend BOOST_HTTP_DECL result hash(core::string_view, unsigned, version); - friend BOOST_HTTP_DECL result hash(core::string_view, core::string_view, system::error_code&); + friend BOOST_HTTP_DECL result hash(core::string_view, core::string_view, std::error_code&); char* buf() noexcept { return buf_; } void set_size(unsigned char n) noexcept @@ -344,7 +326,7 @@ result hash( core::string_view password, core::string_view salt, - system::error_code& ec); + std::error_code& ec); /** Compare a password against a hash. @@ -373,7 +355,7 @@ bool compare( core::string_view password, core::string_view hash, - system::error_code& ec); + std::error_code& ec); /** Extract the cost factor from a hash string. @@ -395,7 +377,7 @@ BOOST_HTTP_DECL unsigned get_rounds( core::string_view hash, - system::error_code& ec); + std::error_code& ec); namespace detail { @@ -507,9 +489,9 @@ compare_task( { detail::password_buf pw(password); detail::hash_buf hs(hash_str); - system::error_code ec; + std::error_code ec; bool ok = compare(pw, hs, ec); - if(ec.failed()) + if(ec) http::detail::throw_system_error(ec); co_return ok; } diff --git a/include/boost/http/brotli/impl/error.hpp b/include/boost/http/brotli/impl/error.hpp index a9d88db8..70ad0756 100644 --- a/include/boost/http/brotli/impl/error.hpp +++ b/include/boost/http/brotli/impl/error.hpp @@ -13,22 +13,8 @@ #include -#include -#include #include -namespace boost { - -namespace system { -template<> -struct is_error_code_enum< - ::boost::http::brotli::error> -{ - static bool const value = true; -}; -} // system -} // boost - namespace std { template<> struct is_error_code_enum< @@ -44,21 +30,13 @@ namespace detail { struct BOOST_SYMBOL_VISIBLE error_cat_type - : system::error_category + : std::error_category { BOOST_HTTP_DECL const char* name( ) const noexcept override; - BOOST_HTTP_DECL bool failed( - int) const noexcept override; BOOST_HTTP_DECL std::string message( int) const override; - BOOST_HTTP_DECL char const* message( - int, char*, std::size_t - ) const noexcept override; - BOOST_SYSTEM_CONSTEXPR error_cat_type() - : error_category(0xc38951ab8832fb6f) - { - } + constexpr error_cat_type() noexcept = default; }; BOOST_HTTP_DECL extern @@ -67,12 +45,11 @@ BOOST_HTTP_DECL extern } // detail inline -BOOST_SYSTEM_CONSTEXPR -system::error_code +std::error_code make_error_code( error ev) noexcept { - return system::error_code{ + return std::error_code{ static_cast::type>(ev), detail::error_cat}; diff --git a/include/boost/http/detail/config.hpp b/include/boost/http/detail/config.hpp index 078743f2..b788b203 100644 --- a/include/boost/http/detail/config.hpp +++ b/include/boost/http/detail/config.hpp @@ -61,22 +61,6 @@ namespace http { # define BOOST_HTTP_AGGREGATE_WORKAROUND #endif -// Add source location to error codes -#ifdef BOOST_HTTP_NO_SOURCE_LOCATION -# define BOOST_HTTP_ERR(ev) (::boost::system::error_code(ev)) -# define BOOST_HTTP_RETURN_EC(ev) return (ev) -#else -# define BOOST_HTTP_ERR(ev) ( \ - ::boost::system::error_code( (ev), [] { \ - static constexpr auto loc((BOOST_CURRENT_LOCATION)); \ - return &loc; }())) -# define BOOST_HTTP_RETURN_EC(ev) \ - do { \ - static constexpr auto loc ## __LINE__((BOOST_CURRENT_LOCATION)); \ - return ::boost::system::error_code((ev), &loc ## __LINE__); \ - } while(0) -#endif - } // http // lift grammar into our namespace diff --git a/include/boost/http/detail/except.hpp b/include/boost/http/detail/except.hpp index 5500ee33..9e5aeb31 100644 --- a/include/boost/http/detail/except.hpp +++ b/include/boost/http/detail/except.hpp @@ -48,7 +48,7 @@ BOOST_HTTP_DECL void BOOST_NORETURN throw_runtime_error( source_location const& loc = BOOST_CURRENT_LOCATION); BOOST_HTTP_DECL void BOOST_NORETURN throw_system_error( - system::error_code const& ec, + std::error_code const& ec, source_location const& loc = BOOST_CURRENT_LOCATION); BOOST_HTTP_DECL void BOOST_NORETURN throw_system_error( diff --git a/include/boost/http/detail/file_posix.hpp b/include/boost/http/detail/file_posix.hpp index d11d66e7..6340105f 100644 --- a/include/boost/http/detail/file_posix.hpp +++ b/include/boost/http/detail/file_posix.hpp @@ -30,7 +30,7 @@ #include #include -#include +#include #include namespace boost { @@ -80,31 +80,31 @@ class file_posix BOOST_HTTP_DECL void - close(system::error_code& ec); + close(std::error_code& ec); BOOST_HTTP_DECL void - open(char const* path, file_mode mode, system::error_code& ec); + open(char const* path, file_mode mode, std::error_code& ec); BOOST_HTTP_DECL std::uint64_t - size(system::error_code& ec) const; + size(std::error_code& ec) const; BOOST_HTTP_DECL std::uint64_t - pos(system::error_code& ec) const; + pos(std::error_code& ec) const; BOOST_HTTP_DECL void - seek(std::uint64_t offset, system::error_code& ec); + seek(std::uint64_t offset, std::error_code& ec); BOOST_HTTP_DECL std::size_t - read(void* buffer, std::size_t n, system::error_code& ec); + read(void* buffer, std::size_t n, std::error_code& ec); BOOST_HTTP_DECL std::size_t - write(void const* buffer, std::size_t n, system::error_code& ec); + write(void const* buffer, std::size_t n, std::error_code& ec); }; } // detail diff --git a/include/boost/http/detail/file_stdio.hpp b/include/boost/http/detail/file_stdio.hpp index 9ab94c4b..7f51525b 100644 --- a/include/boost/http/detail/file_stdio.hpp +++ b/include/boost/http/detail/file_stdio.hpp @@ -58,31 +58,31 @@ class file_stdio BOOST_HTTP_DECL void - close(system::error_code& ec); + close(std::error_code& ec); BOOST_HTTP_DECL void - open(char const* path, file_mode mode, system::error_code& ec); + open(char const* path, file_mode mode, std::error_code& ec); BOOST_HTTP_DECL std::uint64_t - size(system::error_code& ec) const; + size(std::error_code& ec) const; BOOST_HTTP_DECL std::uint64_t - pos(system::error_code& ec) const; + pos(std::error_code& ec) const; BOOST_HTTP_DECL void - seek(std::uint64_t offset, system::error_code& ec); + seek(std::uint64_t offset, std::error_code& ec); BOOST_HTTP_DECL std::size_t - read(void* buffer, std::size_t n, system::error_code& ec); + read(void* buffer, std::size_t n, std::error_code& ec); BOOST_HTTP_DECL std::size_t - write(void const* buffer, std::size_t n, system::error_code& ec); + write(void const* buffer, std::size_t n, std::error_code& ec); }; } // detail diff --git a/include/boost/http/detail/file_win32.hpp b/include/boost/http/detail/file_win32.hpp index dcad6339..9f6c82bc 100644 --- a/include/boost/http/detail/file_win32.hpp +++ b/include/boost/http/detail/file_win32.hpp @@ -70,31 +70,31 @@ class file_win32 BOOST_HTTP_DECL void - close(system::error_code& ec); + close(std::error_code& ec); BOOST_HTTP_DECL void - open(char const* path, file_mode mode, system::error_code& ec); + open(char const* path, file_mode mode, std::error_code& ec); BOOST_HTTP_DECL std::uint64_t - size(system::error_code& ec) const; + size(std::error_code& ec) const; BOOST_HTTP_DECL std::uint64_t - pos(system::error_code& ec) const; + pos(std::error_code& ec) const; BOOST_HTTP_DECL void - seek(std::uint64_t offset, system::error_code& ec); + seek(std::uint64_t offset, std::error_code& ec); BOOST_HTTP_DECL std::size_t - read(void* buffer, std::size_t n, system::error_code& ec); + read(void* buffer, std::size_t n, std::error_code& ec); BOOST_HTTP_DECL std::size_t - write(void const* buffer, std::size_t n, system::error_code& ec); + write(void const* buffer, std::size_t n, std::error_code& ec); }; } // detail diff --git a/include/boost/http/detail/header.hpp b/include/boost/http/detail/header.hpp index cead9747..85dd95f1 100644 --- a/include/boost/http/detail/header.hpp +++ b/include/boost/http/detail/header.hpp @@ -148,9 +148,9 @@ struct header struct request_tag {}; struct response_tag {}; - constexpr header(fields_tag) noexcept; - constexpr header(request_tag) noexcept; - constexpr header(response_tag) noexcept; + header(fields_tag) noexcept; + header(request_tag) noexcept; + header(response_tag) noexcept; public: // in fields_base.hpp @@ -219,7 +219,7 @@ struct header void parse( std::size_t, header_limits const&, - system::error_code&) noexcept; + std::error_code&) noexcept; }; } // detail diff --git a/include/boost/http/fields_base.hpp b/include/boost/http/fields_base.hpp index e83b7245..49db7353 100644 --- a/include/boost/http/fields_base.hpp +++ b/include/boost/http/fields_base.hpp @@ -637,7 +637,7 @@ class fields_base field id, core::string_view value) { - system::error_code ec; + std::error_code ec; append(id, value, ec); if(ec) detail::throw_system_error(ec); @@ -683,7 +683,7 @@ class fields_base append( field id, core::string_view value, - system::error_code& ec) + std::error_code& ec) { insert_impl( id, @@ -736,7 +736,7 @@ class fields_base core::string_view name, core::string_view value) { - system::error_code ec; + std::error_code ec; append(name, value, ec); if(ec) detail::throw_system_error(ec); @@ -782,7 +782,7 @@ class fields_base append( core::string_view name, core::string_view value, - system::error_code& ec) + std::error_code& ec) { insert_impl( string_to_field(name), @@ -890,7 +890,7 @@ class fields_base iterator before, field id, core::string_view value, - system::error_code& ec); + std::error_code& ec); /** Insert a header. @@ -991,7 +991,7 @@ class fields_base iterator before, core::string_view name, core::string_view value, - system::error_code& ec); + std::error_code& ec); //-------------------------------------------- @@ -1128,7 +1128,7 @@ class fields_base set( iterator it, core::string_view value, - system::error_code& ec); + std::error_code& ec); /** Set a header value. @@ -1171,7 +1171,7 @@ class fields_base field id, core::string_view value) { - system::error_code ec; + std::error_code ec; set(id, value, ec); if(ec) detail::throw_system_error(ec); @@ -1215,7 +1215,7 @@ class fields_base set( field id, core::string_view value, - system::error_code& ec); + std::error_code& ec); /** Set a header value. @@ -1257,7 +1257,7 @@ class fields_base core::string_view name, core::string_view value) { - system::error_code ec; + std::error_code ec; set(name, value, ec); if(ec) detail::throw_system_error(ec); @@ -1301,7 +1301,7 @@ class fields_base set( core::string_view name, core::string_view value, - system::error_code& ec); + std::error_code& ec); //-------------------------------------------- @@ -1356,7 +1356,7 @@ class fields_base core::string_view name, core::string_view value, std::size_t before, - system::error_code& ec); + std::error_code& ec); void insert_unchecked( diff --git a/include/boost/http/file.hpp b/include/boost/http/file.hpp index 787aec7f..ce14c490 100644 --- a/include/boost/http/file.hpp +++ b/include/boost/http/file.hpp @@ -130,7 +130,7 @@ class file @param ec Set to the error, if any occurred. */ void - close(system::error_code& ec) + close(std::error_code& ec) { impl_.close(ec); } @@ -149,7 +149,7 @@ class file void close() { - system::error_code ec; + std::error_code ec; impl_.close(ec); if(ec) detail::throw_system_error(ec); @@ -167,7 +167,7 @@ class file @ref file_mode. */ void - open(char const* path, file_mode mode, system::error_code& ec) + open(char const* path, file_mode mode, std::error_code& ec) { impl_.open(path, mode, ec); } @@ -190,7 +190,7 @@ class file void open(char const* path, file_mode mode) { - system::error_code ec; + std::error_code ec; impl_.open(path, mode, ec); if(ec) detail::throw_system_error(ec); @@ -201,7 +201,7 @@ class file @param ec Set to the error, if any occurred. */ std::uint64_t - size(system::error_code& ec) const + size(std::error_code& ec) const { return impl_.size(ec); } @@ -217,7 +217,7 @@ class file std::uint64_t size() const { - system::error_code ec; + std::error_code ec; auto r = impl_.size(ec); if(ec) detail::throw_system_error(ec); @@ -229,7 +229,7 @@ class file @param ec Set to the error, if any occurred. */ std::uint64_t - pos(system::error_code& ec) const + pos(std::error_code& ec) const { return impl_.pos(ec); } @@ -245,7 +245,7 @@ class file std::uint64_t pos() const { - system::error_code ec; + std::error_code ec; auto r = impl_.pos(ec); if(ec) detail::throw_system_error(ec); @@ -259,7 +259,7 @@ class file @param ec Set to the error, if any occurred. */ void - seek(std::uint64_t offset, system::error_code& ec) + seek(std::uint64_t offset, std::error_code& ec) { impl_.seek(offset, ec); } @@ -277,7 +277,7 @@ class file void seek(std::uint64_t offset) { - system::error_code ec; + std::error_code ec; impl_.seek(offset, ec); if(ec) detail::throw_system_error(ec); @@ -296,7 +296,7 @@ class file @param ec Set to the error, if any occurred. */ std::size_t - read(void* buffer, std::size_t n, system::error_code& ec) + read(void* buffer, std::size_t n, std::error_code& ec) { return impl_.read(buffer, n, ec); } @@ -319,7 +319,7 @@ class file std::size_t read(void* buffer, std::size_t n) { - system::error_code ec; + std::error_code ec; auto r = impl_.read(buffer, n, ec); if(ec) detail::throw_system_error(ec); @@ -339,7 +339,7 @@ class file @param ec Set to the error, if any occurred. */ std::size_t - write(void const* buffer, std::size_t n, system::error_code& ec) + write(void const* buffer, std::size_t n, std::error_code& ec) { return impl_.write(buffer, n, ec); } @@ -361,7 +361,7 @@ class file std::size_t write(void const* buffer, std::size_t n) { - system::error_code ec; + std::error_code ec; auto r = impl_.write(buffer, n, ec); if(ec) detail::throw_system_error(ec); diff --git a/include/boost/http/impl/error.hpp b/include/boost/http/impl/error.hpp index 9baba35f..fd98a002 100644 --- a/include/boost/http/impl/error.hpp +++ b/include/boost/http/impl/error.hpp @@ -10,33 +10,8 @@ #ifndef BOOST_HTTP_IMPL_ERROR_HPP #define BOOST_HTTP_IMPL_ERROR_HPP -#include -#include -#include -#include #include -namespace boost { - -namespace system { - -template<> -struct is_error_code_enum< - ::boost::http::error> -{ - static bool const value = true; -}; - -template<> -struct is_error_condition_enum< - ::boost::http::condition> -{ - static bool const value = true; -}; - -} // system -} // boost - namespace std { template<> struct is_error_code_enum< @@ -59,39 +34,27 @@ namespace detail { struct BOOST_HTTP_SYMBOL_VISIBLE error_cat_type - : system::error_category + : std::error_category { BOOST_HTTP_DECL const char* name( ) const noexcept override; BOOST_HTTP_DECL std::string message( int) const override; - BOOST_HTTP_DECL char const* message( - int, char*, std::size_t - ) const noexcept override; - BOOST_SYSTEM_CONSTEXPR error_cat_type() - : error_category(0x3663257e7585fbfd) - { - } + constexpr error_cat_type() noexcept = default; }; struct BOOST_HTTP_SYMBOL_VISIBLE condition_cat_type - : system::error_category + : std::error_category { BOOST_HTTP_DECL const char* name( ) const noexcept override; BOOST_HTTP_DECL std::string message( int) const override; - BOOST_HTTP_DECL char const* message( - int, char*, std::size_t - ) const noexcept override; BOOST_HTTP_DECL bool equivalent( - system::error_code const&, int + std::error_code const&, int ) const noexcept override; - BOOST_SYSTEM_CONSTEXPR condition_cat_type() - : error_category(0xa36e10f16c666a7) - { - } + constexpr condition_cat_type() noexcept = default; }; BOOST_HTTP_DECL extern @@ -102,24 +65,22 @@ BOOST_HTTP_DECL extern } // detail inline -BOOST_SYSTEM_CONSTEXPR -system::error_code +std::error_code make_error_code( error ev) noexcept { - return system::error_code{ + return std::error_code{ static_cast::type>(ev), detail::error_cat}; } inline -BOOST_SYSTEM_CONSTEXPR -system::error_condition +std::error_condition make_error_condition( condition c) noexcept { - return system::error_condition{ + return std::error_condition{ static_cast::type>(c), detail::condition_cat}; diff --git a/include/boost/http/metadata.hpp b/include/boost/http/metadata.hpp index 376a338f..d6d9182f 100644 --- a/include/boost/http/metadata.hpp +++ b/include/boost/http/metadata.hpp @@ -12,7 +12,7 @@ #define BOOST_HTTP_METADATA_HPP #include -#include +#include #include #include @@ -69,7 +69,7 @@ struct metadata { /** Error status of Connection. */ - system::error_code ec; + std::error_code ec; /** The total number of fields. */ @@ -88,12 +88,9 @@ struct metadata bool upgrade = false; #ifdef BOOST_HTTP_AGGREGATE_WORKAROUND - constexpr connection_t() = default; - - constexpr connection_t( - system::error_code ec_, + std::error_code ec_, std::size_t count_, bool close_, bool keep_alive_, @@ -116,7 +113,7 @@ struct metadata { /** Error status of Content-Encoding. */ - system::error_code ec; + std::error_code ec; /** The total number of fields. */ @@ -128,12 +125,9 @@ struct metadata content_coding::identity; #ifdef BOOST_HTTP_AGGREGATE_WORKAROUND - constexpr content_encoding_t() = default; - - constexpr content_encoding_t( - system::error_code ec_, + std::error_code ec_, std::size_t count_, content_coding coding_) noexcept : ec(ec_) @@ -152,7 +146,7 @@ struct metadata { /** Error status of Content-Length. */ - system::error_code ec; + std::error_code ec; /** The total number of fields. */ @@ -167,12 +161,9 @@ struct metadata std::uint64_t value = 0; #ifdef BOOST_HTTP_AGGREGATE_WORKAROUND - constexpr content_length_t() = default; - - constexpr content_length_t( - system::error_code ec_, + std::error_code ec_, std::size_t count_, std::uint64_t value_) noexcept : ec(ec_) @@ -191,7 +182,7 @@ struct metadata { /** Error status of Expect. */ - system::error_code ec; + std::error_code ec; /** The total number of fields. */ @@ -202,12 +193,9 @@ struct metadata bool is_100_continue = false; #ifdef BOOST_HTTP_AGGREGATE_WORKAROUND - constexpr expect_t() = default; - - constexpr expect_t( - system::error_code ec_, + std::error_code ec_, std::size_t count_, bool is_100_continue_) noexcept : ec(ec_) @@ -226,7 +214,7 @@ struct metadata { /** Error status of Content-Length. */ - system::error_code ec; + std::error_code ec; /** The total number of fields. */ @@ -237,12 +225,9 @@ struct metadata bool is_chunked = false; #ifdef BOOST_HTTP_AGGREGATE_WORKAROUND - constexpr transfer_encoding_t() = default; - - constexpr transfer_encoding_t( - system::error_code ec_, + std::error_code ec_, std::size_t count_, bool is_chunked_) noexcept : ec(ec_) @@ -261,7 +246,7 @@ struct metadata { /** Error status of Upgrade. */ - system::error_code ec; + std::error_code ec; /** The total number of fields. */ @@ -272,12 +257,9 @@ struct metadata bool websocket = false; #ifdef BOOST_HTTP_AGGREGATE_WORKAROUND - constexpr upgrade_t() = default; - - constexpr upgrade_t( - system::error_code ec_, + std::error_code ec_, std::size_t count_, bool websocket_) noexcept : ec(ec_) @@ -342,7 +324,7 @@ struct metadata /** Constructor. */ - constexpr metadata() = default; + metadata() = default; }; } // http diff --git a/include/boost/http/parser.hpp b/include/boost/http/parser.hpp index 3dcf351c..9de7ce97 100644 --- a/include/boost/http/parser.hpp +++ b/include/boost/http/parser.hpp @@ -200,7 +200,7 @@ class parser BOOST_HTTP_DECL void parse( - system::error_code& ec); + std::error_code& ec); /** Set maximum body size for the current message. @@ -541,7 +541,7 @@ capy::io_task<> parser:: read_header(Stream& stream) { - system::error_code ec; + std::error_code ec; for(;;) { parse(ec); @@ -569,7 +569,7 @@ capy::io_task<> parser:: read(Stream& stream) { - system::error_code ec; + std::error_code ec; for(;;) { parse(ec); @@ -608,7 +608,7 @@ read(Stream& stream, MB buffers) for(;;) { - system::error_code ec; + std::error_code ec; parse(ec); if(got_header()) @@ -672,7 +672,7 @@ pull(std::span dest) for(;;) { - system::error_code ec; + std::error_code ec; pr_->parse(ec); auto body_data = pr_->pull_body(); @@ -722,7 +722,7 @@ read(capy::ReadStream auto& stream, Sink&& sink) { for(;;) { - system::error_code ec; + std::error_code ec; parse(ec); if(got_header()) diff --git a/include/boost/http/server/route_handler.hpp b/include/boost/http/server/route_handler.hpp index b77cf945..5f12ac8c 100644 --- a/include/boost/http/server/route_handler.hpp +++ b/include/boost/http/server/route_handler.hpp @@ -26,8 +26,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -105,12 +104,12 @@ enum class route_what class BOOST_HTTP_DECL route_result { - system::error_code ec_; + std::error_code ec_; template struct what_t {}; - route_result(system::error_code ec); + route_result(std::error_code ec); void set(route_what w); public: @@ -172,7 +171,7 @@ class BOOST_HTTP_DECL */ auto error() const noexcept -> - system::error_code; + std::error_code; /** Return true if the result indicates an error. @@ -187,12 +186,12 @@ class BOOST_HTTP_DECL static constexpr route_result::what_t route_next{}; static constexpr route_result::what_t route_next_route{}; static constexpr route_result::what_t route_close{}; - friend route_result route_error(system::error_code ec) noexcept; + friend route_result route_error(std::error_code ec) noexcept; template friend auto route_error(E e) noexcept -> std::enable_if_t< - system::is_error_code_enum::value, + std::is_error_code_enum::value, route_result>; }; @@ -276,7 +275,7 @@ inline constexpr decltype(auto) route_close = route_result::route_close; @throw std::invalid_argument if `!ec` (non-failing code). */ -inline route_result route_error(system::error_code ec) noexcept +inline route_result route_error(std::error_code ec) noexcept { return route_result(ec); } @@ -291,7 +290,7 @@ inline route_result route_error(system::error_code ec) noexcept template auto route_error(E e) noexcept -> std::enable_if_t< - system::is_error_code_enum::value, + std::is_error_code_enum::value, route_result> { return route_result(make_error_code(e)); @@ -341,7 +340,7 @@ struct route_params_base_privates { std::string verb_str_; std::string decoded_path_; - system::error_code ec_; + std::error_code ec_; std::exception_ptr ep_; std::size_t pos_ = 0; std::size_t resume_ = 0; diff --git a/include/boost/http/server/router.hpp b/include/boost/http/server/router.hpp index e5102344..6abc3a87 100644 --- a/include/boost/http/server/router.hpp +++ b/include/boost/http/server/router.hpp @@ -224,8 +224,8 @@ struct identity The return value is a @ref route_result used to indicate the desired action through @ref route enum values, or to indicate that a failure - occurred. Failures are represented by error codes for which - `system::error_code::failed()` returns `true`. + occurred. Failures are represented by error codes which + contextually convert to `true`. When a failing error code is produced and remains unhandled, the router enters error-dispatching mode. In this mode, only error @@ -235,10 +235,10 @@ struct identity Error handlers have this equivalent signature: @code - route_result error_handler( Params& p, system::error_code ec ) + route_result error_handler( Params& p, std::error_code ec ) @endcode - Each error handler may return any failing @ref system::error_code, + Each error handler may return any failing @ref std::error_code, which is equivalent to calling: @code p.next( ec ); // with ec == true @@ -402,7 +402,7 @@ class router : public detail::router_base []() -> char { if constexpr (detail::returns_route_task< - T, P&, system::error_code>) + T, P&, std::error_code>) { return is_error; } @@ -464,7 +464,7 @@ class router : public detail::router_base return h(static_cast(rp)); } else if constexpr (detail::returns_route_task< - H, P&, system::error_code>) + H, P&, std::error_code>) { return h(static_cast(rp), rp.priv_.ec_); } @@ -526,7 +526,7 @@ class router : public detail::router_base { if constexpr ( detail::returns_route_task< - H1, P&, system::error_code> || + H1, P&, std::error_code> || detail::returns_route_task< H1, P&, std::exception_ptr>) { diff --git a/include/boost/http/zlib/impl/error.hpp b/include/boost/http/zlib/impl/error.hpp index 6e9b2bf3..fcb6cc39 100644 --- a/include/boost/http/zlib/impl/error.hpp +++ b/include/boost/http/zlib/impl/error.hpp @@ -13,22 +13,8 @@ #include -#include -#include #include -namespace boost { - -namespace system { -template<> -struct is_error_code_enum< - ::boost::http::zlib::error> -{ - static bool const value = true; -}; -} // system -} // boost - namespace std { template<> struct is_error_code_enum< @@ -44,21 +30,13 @@ namespace detail { struct BOOST_SYMBOL_VISIBLE error_cat_type - : system::error_category + : std::error_category { BOOST_HTTP_DECL const char* name( ) const noexcept override; - BOOST_HTTP_DECL bool failed( - int) const noexcept override; BOOST_HTTP_DECL std::string message( int) const override; - BOOST_HTTP_DECL char const* message( - int, char*, std::size_t - ) const noexcept override; - BOOST_SYSTEM_CONSTEXPR error_cat_type() - : error_category(0x43fd42f819852b73) - { - } + constexpr error_cat_type() noexcept = default; }; BOOST_HTTP_DECL extern @@ -67,12 +45,11 @@ BOOST_HTTP_DECL extern } // detail inline -BOOST_SYSTEM_CONSTEXPR -system::error_code +std::error_code make_error_code( error ev) noexcept { - return system::error_code{ + return std::error_code{ static_cast::type>(ev), detail::error_cat}; diff --git a/include/boost/http/zstd/impl/error.hpp b/include/boost/http/zstd/impl/error.hpp index e07c8d43..ed8345d0 100644 --- a/include/boost/http/zstd/impl/error.hpp +++ b/include/boost/http/zstd/impl/error.hpp @@ -12,22 +12,8 @@ #include -#include -#include #include -namespace boost { - -namespace system { -template<> -struct is_error_code_enum< - ::boost::http::zstd::error> -{ - static bool const value = true; -}; -} // system -} // boost - namespace std { template<> struct is_error_code_enum< @@ -43,21 +29,13 @@ namespace detail { struct BOOST_SYMBOL_VISIBLE error_cat_type - : system::error_category + : std::error_category { BOOST_HTTP_DECL const char* name( ) const noexcept override; - BOOST_HTTP_DECL bool failed( - int) const noexcept override; BOOST_HTTP_DECL std::string message( int) const override; - BOOST_HTTP_DECL char const* message( - int, char*, std::size_t - ) const noexcept override; - BOOST_SYSTEM_CONSTEXPR error_cat_type() - : error_category(0x9971e0803a6de4e7) - { - } + constexpr error_cat_type() noexcept = default; }; BOOST_HTTP_DECL extern @@ -66,12 +44,11 @@ BOOST_HTTP_DECL extern } // detail inline -BOOST_SYSTEM_CONSTEXPR -system::error_code +std::error_code make_error_code( error ev) noexcept { - return system::error_code{ + return std::error_code{ static_cast::type>(ev), detail::error_cat}; diff --git a/src/bcrypt/error.cpp b/src/bcrypt/error.cpp index 66e26a51..01335ef7 100644 --- a/src/bcrypt/error.cpp +++ b/src/bcrypt/error.cpp @@ -24,16 +24,6 @@ name() const noexcept std::string error_cat_type:: message(int ev) const -{ - return message(ev, nullptr, 0); -} - -char const* -error_cat_type:: -message( - int ev, - char*, - std::size_t) const noexcept { switch(static_cast(ev)) { diff --git a/src/bcrypt/hash.cpp b/src/bcrypt/hash.cpp index bd4f4a76..1e763661 100644 --- a/src/bcrypt/hash.cpp +++ b/src/bcrypt/hash.cpp @@ -81,7 +81,7 @@ result hash( core::string_view password, core::string_view salt, - system::error_code& ec) + std::error_code& ec) { ec = {}; @@ -122,7 +122,7 @@ bool compare( core::string_view password, core::string_view hash_str, - system::error_code& ec) + std::error_code& ec) { ec = {}; @@ -173,7 +173,7 @@ compare( unsigned get_rounds( core::string_view hash_str, - system::error_code& ec) + std::error_code& ec) { ec = {}; diff --git a/src/bcrypt/random.cpp b/src/bcrypt/random.cpp index c52488f7..5a7b19f7 100644 --- a/src/bcrypt/random.cpp +++ b/src/bcrypt/random.cpp @@ -9,7 +9,7 @@ #include "random.hpp" #include -#include +#include #if defined(_WIN32) # ifndef WIN32_LEAN_AND_MEAN @@ -90,9 +90,9 @@ fill_random(void* buf, std::size_t n) if (!get_rng().generate(buf, n)) { http::detail::throw_system_error( - system::error_code( + std::error_code( static_cast(GetLastError()), - system::system_category())); + std::system_category())); } } @@ -110,9 +110,9 @@ fill_random(void* buf, std::size_t n) if (errno == EINTR) continue; http::detail::throw_system_error( - system::error_code( + std::error_code( errno, - system::system_category())); + std::system_category())); } p += r; n -= static_cast(r); @@ -128,9 +128,9 @@ fill_random(void* buf, std::size_t n) if (err != errSecSuccess) { http::detail::throw_system_error( - system::error_code( + std::error_code( err, - system::system_category())); + std::system_category())); } } @@ -147,9 +147,9 @@ fill_random(void* buf, std::size_t n) if (fd < 0) { http::detail::throw_system_error( - system::error_code( + std::error_code( errno, - system::system_category())); + std::system_category())); } } @@ -162,9 +162,9 @@ fill_random(void* buf, std::size_t n) if (errno == EINTR) continue; http::detail::throw_system_error( - system::error_code( + std::error_code( errno, - system::system_category())); + std::system_category())); } if (r == 0) { diff --git a/src/bcrypt/random.hpp b/src/bcrypt/random.hpp index 30dc0a6f..26807379 100644 --- a/src/bcrypt/random.hpp +++ b/src/bcrypt/random.hpp @@ -10,7 +10,7 @@ #ifndef BOOST_HTTP_SRC_BCRYPT_RANDOM_HPP #define BOOST_HTTP_SRC_BCRYPT_RANDOM_HPP -#include +#include #include namespace boost { diff --git a/src/brotli/error.cpp b/src/brotli/error.cpp index 9f5a3459..7057c794 100644 --- a/src/brotli/error.cpp +++ b/src/brotli/error.cpp @@ -21,26 +21,9 @@ name() const noexcept return "boost.http.brotli"; } -bool -error_cat_type:: -failed(int ev) const noexcept -{ - return ev < 0; -} - std::string error_cat_type:: message(int ev) const -{ - return message(ev, nullptr, 0); -} - -char const* -error_cat_type:: -message( - int ev, - char*, - std::size_t) const noexcept { switch(static_cast(ev)) { diff --git a/src/detail/except.cpp b/src/detail/except.cpp index 7d9c9fcf..87bfdc33 100644 --- a/src/detail/except.cpp +++ b/src/detail/except.cpp @@ -8,10 +8,10 @@ // #include -#include #include #include #include +#include #include namespace boost { @@ -100,11 +100,11 @@ throw_runtime_error( void throw_system_error( - system::error_code const& ec, + std::error_code const& ec, source_location const& loc) { throw_exception( - system::system_error(ec), loc); + std::system_error(ec), loc); } void @@ -113,7 +113,8 @@ throw_system_error( source_location const& loc) { throw_exception( - system::system_error(e), loc); + std::system_error( + make_error_code(e)), loc); } } // detail diff --git a/src/detail/file_posix.cpp b/src/detail/file_posix.cpp index 2538f34e..6a9a0632 100644 --- a/src/detail/file_posix.cpp +++ b/src/detail/file_posix.cpp @@ -105,24 +105,24 @@ native_handle(native_handle_type fd) void file_posix:: close( - system::error_code& ec) + std::error_code& ec) { auto const ev = native_close(fd_); if(ev) ec.assign(ev, - system::system_category()); + std::system_category()); else ec = {}; } void file_posix:: -open(char const* path, file_mode mode, system::error_code& ec) +open(char const* path, file_mode mode, std::error_code& ec) { auto const ev = native_close(fd_); if(ev) ec.assign(ev, - system::system_category()); + std::system_category()); else ec = {}; @@ -190,7 +190,7 @@ open(char const* path, file_mode mode, system::error_code& ec) if(ev != EINTR) { ec.assign(ev, - system::system_category()); + std::system_category()); return; } } @@ -200,7 +200,7 @@ open(char const* path, file_mode mode, system::error_code& ec) auto const ev = errno; native_close(fd_); ec.assign(ev, - system::system_category()); + std::system_category()); return; } #endif @@ -210,19 +210,19 @@ open(char const* path, file_mode mode, system::error_code& ec) std::uint64_t file_posix:: size( - system::error_code& ec) const + std::error_code& ec) const { if(fd_ == -1) { ec = make_error_code( - system::errc::bad_file_descriptor); + std::errc::bad_file_descriptor); return 0; } struct stat st; if(::fstat(fd_, &st) != 0) { ec.assign(errno, - system::system_category()); + std::system_category()); return 0; } ec = {}; @@ -232,19 +232,19 @@ size( std::uint64_t file_posix:: pos( - system::error_code& ec) const + std::error_code& ec) const { if(fd_ == -1) { ec = make_error_code( - system::errc::bad_file_descriptor); + std::errc::bad_file_descriptor); return 0; } auto const result = ::lseek(fd_, 0, SEEK_CUR); if(result == (::off_t)-1) { ec.assign(errno, - system::system_category()); + std::system_category()); return 0; } ec = {}; @@ -254,19 +254,19 @@ pos( void file_posix:: seek(std::uint64_t offset, - system::error_code& ec) + std::error_code& ec) { if(fd_ == -1) { ec = make_error_code( - system::errc::bad_file_descriptor); + std::errc::bad_file_descriptor); return; } auto const result = ::lseek(fd_, offset, SEEK_SET); if(result == static_cast<::off_t>(-1)) { ec.assign(errno, - system::system_category()); + std::system_category()); return; } ec = {}; @@ -275,12 +275,12 @@ seek(std::uint64_t offset, std::size_t file_posix:: read(void* buffer, std::size_t n, - system::error_code& ec) + std::error_code& ec) { if(fd_ == -1) { ec = make_error_code( - system::errc::bad_file_descriptor); + std::errc::bad_file_descriptor); return 0; } std::size_t nread = 0; @@ -299,7 +299,7 @@ read(void* buffer, std::size_t n, if(ev == EINTR) continue; ec.assign(ev, - system::system_category()); + std::system_category()); return nread; } if(result == 0) @@ -317,12 +317,12 @@ read(void* buffer, std::size_t n, std::size_t file_posix:: write(void const* buffer, std::size_t n, - system::error_code& ec) + std::error_code& ec) { if(fd_ == -1) { ec = make_error_code( - system::errc::bad_file_descriptor); + std::errc::bad_file_descriptor); return 0; } std::size_t nwritten = 0; @@ -341,7 +341,7 @@ write(void const* buffer, std::size_t n, if(ev == EINTR) continue; ec.assign(ev, - system::system_category()); + std::system_category()); return nwritten; } n -= result; diff --git a/src/detail/file_stdio.cpp b/src/detail/file_stdio.cpp index 118b5492..cd5830b7 100644 --- a/src/detail/file_stdio.cpp +++ b/src/detail/file_stdio.cpp @@ -10,7 +10,7 @@ #include "src/detail/win32_unicode_path.hpp" #include #include -#include +#include #include #include #include @@ -59,7 +59,7 @@ native_handle(std::FILE* f) void file_stdio:: close( - system::error_code& ec) + std::error_code& ec) { if(f_) { @@ -68,7 +68,7 @@ close( if(failed) { ec.assign(errno, - system::generic_category()); + std::generic_category()); return; } } @@ -78,7 +78,7 @@ close( void file_stdio:: open(char const* path, file_mode mode, - system::error_code& ec) + std::error_code& ec) { if(f_) { @@ -133,14 +133,14 @@ open(char const* path, file_mode mode, { std::fclose(f0); ec = make_error_code( - system::errc::file_exists); + std::errc::file_exists); return; } - else if(ev != - system::errc::no_such_file_or_directory) + else if(ev != static_cast( + std::errc::no_such_file_or_directory)) { ec.assign(ev, - system::generic_category()); + std::generic_category()); return; } s = L"wb"; @@ -176,7 +176,7 @@ open(char const* path, file_mode mode, if(ev) { ec.assign(ev, - system::generic_category()); + std::generic_category()); return; } #else @@ -185,7 +185,7 @@ open(char const* path, file_mode mode, if(! f0) { ec.assign(errno, - system::generic_category()); + std::generic_category()); return; } #endif @@ -206,7 +206,7 @@ open(char const* path, file_mode mode, { f_ = nullptr; ec.assign(ev, - system::generic_category()); + std::generic_category()); return; } #else @@ -214,7 +214,7 @@ open(char const* path, file_mode mode, if(! f_) { ec.assign(errno, - system::generic_category()); + std::generic_category()); return; } #endif @@ -223,40 +223,40 @@ open(char const* path, file_mode mode, std::uint64_t file_stdio:: size( - system::error_code& ec) const + std::error_code& ec) const { if(! f_) { ec = make_error_code( - system::errc::bad_file_descriptor); + std::errc::bad_file_descriptor); return 0; } long pos = std::ftell(f_); if(pos == -1L) { ec.assign(errno, - system::generic_category()); + std::generic_category()); return 0; } int result = std::fseek(f_, 0, SEEK_END); if(result != 0) { ec.assign(errno, - system::generic_category()); + std::generic_category()); return 0; } long size = std::ftell(f_); if(size == -1L) { ec.assign(errno, - system::generic_category()); + std::generic_category()); std::fseek(f_, pos, SEEK_SET); return 0; } result = std::fseek(f_, pos, SEEK_SET); if(result != 0) ec.assign(errno, - system::generic_category()); + std::generic_category()); else ec = {}; return size; @@ -265,19 +265,19 @@ size( std::uint64_t file_stdio:: pos( - system::error_code& ec) const + std::error_code& ec) const { if(! f_) { ec = make_error_code( - system::errc::bad_file_descriptor); + std::errc::bad_file_descriptor); return 0; } long pos = std::ftell(f_); if(pos == -1L) { ec.assign(errno, - system::generic_category()); + std::generic_category()); return 0; } ec = {}; @@ -287,25 +287,25 @@ pos( void file_stdio:: seek(std::uint64_t offset, - system::error_code& ec) + std::error_code& ec) { if(! f_) { ec = make_error_code( - system::errc::bad_file_descriptor); + std::errc::bad_file_descriptor); return; } if(offset > static_cast((std::numeric_limits::max)())) { ec = make_error_code( - system::errc::invalid_seek); + std::errc::invalid_seek); return; } int result = std::fseek(f_, static_cast(offset), SEEK_SET); if(result != 0) ec.assign(errno, - system::generic_category()); + std::generic_category()); else ec = {}; } @@ -313,19 +313,19 @@ seek(std::uint64_t offset, std::size_t file_stdio:: read(void* buffer, std::size_t n, - system::error_code& ec) + std::error_code& ec) { if(! f_) { ec = make_error_code( - system::errc::bad_file_descriptor); + std::errc::bad_file_descriptor); return 0; } auto nread = std::fread(buffer, 1, n, f_); if(std::ferror(f_)) { ec.assign(errno, - system::generic_category()); + std::generic_category()); return 0; } return nread; @@ -334,19 +334,19 @@ read(void* buffer, std::size_t n, std::size_t file_stdio:: write(void const* buffer, std::size_t n, - system::error_code& ec) + std::error_code& ec) { if(! f_) { ec = make_error_code( - system::errc::bad_file_descriptor); + std::errc::bad_file_descriptor); return 0; } auto nwritten = std::fwrite(buffer, 1, n, f_); if(std::ferror(f_)) { ec.assign(errno, - system::generic_category()); + std::generic_category()); return 0; } return nwritten; diff --git a/src/detail/file_win32.cpp b/src/detail/file_win32.cpp index e22e392e..40b614f0 100644 --- a/src/detail/file_win32.cpp +++ b/src/detail/file_win32.cpp @@ -13,7 +13,7 @@ #include "src/detail/win32_unicode_path.hpp" #include -#include +#include #include #include #include @@ -91,14 +91,14 @@ native_handle(native_handle_type h) void file_win32:: close( - system::error_code& ec) + std::error_code& ec) { if(h_ != winapi::INVALID_HANDLE_VALUE_) { if(! winapi::CloseHandle(h_)) ec.assign( winapi::GetLastError(), - system::system_category()); + std::system_category()); else ec = {}; h_ = winapi::INVALID_HANDLE_VALUE_; @@ -112,7 +112,7 @@ close( void file_win32:: open(char const* path, file_mode mode, - system::error_code& ec) + std::error_code& ec) { if(h_ != winapi::INVALID_HANDLE_VALUE_) { @@ -201,7 +201,7 @@ open(char const* path, file_mode mode, if (h_ == winapi::INVALID_HANDLE_VALUE_) { ec.assign(winapi::GetLastError(), - system::system_category()); + std::system_category()); return; } if (mode == file_mode::append || @@ -213,7 +213,7 @@ open(char const* path, file_mode mode, winapi::FILE_END_)) { ec.assign(winapi::GetLastError(), - system::system_category()); + std::system_category()); winapi::CloseHandle(h_); h_ = winapi::INVALID_HANDLE_VALUE_; return; @@ -225,19 +225,19 @@ open(char const* path, file_mode mode, std::uint64_t file_win32:: size( - system::error_code& ec) const + std::error_code& ec) const { if(h_ == winapi::INVALID_HANDLE_VALUE_) { ec = make_error_code( - system::errc::bad_file_descriptor); + std::errc::bad_file_descriptor); return 0; } winapi::LARGE_INTEGER_ fileSize; if(! winapi::GetFileSizeEx(h_, &fileSize)) { ec.assign(winapi::GetLastError(), - system::system_category()); + std::system_category()); return 0; } ec = {}; @@ -247,12 +247,12 @@ size( std::uint64_t file_win32:: pos( - system::error_code& ec) const + std::error_code& ec) const { if(h_ == winapi::INVALID_HANDLE_VALUE_) { ec = make_error_code( - system::errc::bad_file_descriptor); + std::errc::bad_file_descriptor); return 0; } winapi::LARGE_INTEGER_ in; @@ -262,7 +262,7 @@ pos( winapi::FILE_CURRENT_)) { ec.assign(winapi::GetLastError(), - system::system_category()); + std::system_category()); return 0; } ec = {}; @@ -272,12 +272,12 @@ pos( void file_win32:: seek(std::uint64_t offset, - system::error_code& ec) + std::error_code& ec) { if(h_ == winapi::INVALID_HANDLE_VALUE_) { ec = make_error_code( - system::errc::bad_file_descriptor); + std::errc::bad_file_descriptor); return; } winapi::LARGE_INTEGER_ in; @@ -286,7 +286,7 @@ seek(std::uint64_t offset, winapi::FILE_BEGIN_)) { ec.assign(winapi::GetLastError(), - system::system_category()); + std::system_category()); return; } ec = {}; @@ -295,12 +295,12 @@ seek(std::uint64_t offset, std::size_t file_win32:: read(void* buffer, std::size_t n, - system::error_code& ec) + std::error_code& ec) { if(h_ == winapi::INVALID_HANDLE_VALUE_) { ec = make_error_code( - system::errc::bad_file_descriptor); + std::errc::bad_file_descriptor); return 0; } std::size_t nread = 0; @@ -320,7 +320,7 @@ read(void* buffer, std::size_t n, auto const dwError = winapi::GetLastError(); if(dwError != winapi::ERROR_HANDLE_EOF_) ec.assign(dwError, - system::system_category()); + std::system_category()); else ec = {}; return nread; @@ -338,12 +338,12 @@ read(void* buffer, std::size_t n, std::size_t file_win32:: write(void const* buffer, std::size_t n, - system::error_code& ec) + std::error_code& ec) { if(h_ == winapi::INVALID_HANDLE_VALUE_) { ec = make_error_code( - system::errc::bad_file_descriptor); + std::errc::bad_file_descriptor); return 0; } std::size_t nwritten = 0; @@ -363,7 +363,7 @@ write(void const* buffer, std::size_t n, auto const dwError = winapi::GetLastError(); if(dwError != winapi::ERROR_HANDLE_EOF_) ec.assign(dwError, - system::system_category()); + std::system_category()); else ec = {}; return nwritten; diff --git a/src/detail/filter.hpp b/src/detail/filter.hpp index e5dcffad..6c26b41a 100644 --- a/src/detail/filter.hpp +++ b/src/detail/filter.hpp @@ -13,7 +13,7 @@ #include #include -#include +#include #include @@ -34,7 +34,7 @@ class filter { /** The error, if any occurred. */ - system::error_code ec; + std::error_code ec; /** The number of bytes produced in the output. diff --git a/src/detail/header.cpp b/src/detail/header.cpp index acc684ba..79637a91 100644 --- a/src/detail/header.cpp +++ b/src/detail/header.cpp @@ -74,7 +74,6 @@ constexpr field header::unknown_field; //------------------------------------------------ -constexpr header:: header(fields_tag) noexcept : kind(detail::kind::fields) @@ -84,7 +83,6 @@ header(fields_tag) noexcept { } -constexpr header:: header(request_tag) noexcept : kind(detail::kind::request) @@ -96,7 +94,6 @@ header(request_tag) noexcept { } -constexpr header:: header(response_tag) noexcept : kind(detail::kind::response) @@ -114,7 +111,7 @@ header const* header:: get_default(detail::kind k) noexcept { - static constexpr header h[3] = { + static header const h[3] = { fields_tag{}, request_tag{}, response_tag{}}; @@ -490,8 +487,7 @@ on_insert_connection( if(! rv) { md.connection.ec = - BOOST_HTTP_ERR( - error::bad_connection); + error::bad_connection; return; } md.connection.ec = {}; @@ -528,8 +524,7 @@ on_insert_content_length( { // parse failure md.content_length.ec = - BOOST_HTTP_ERR( - error::bad_content_length); + error::bad_content_length; md.content_length.value = 0; update_payload(); return; @@ -549,8 +544,7 @@ on_insert_content_length( } // bad: different values md.content_length.ec = - BOOST_HTTP_ERR( - error::multiple_content_length); + error::multiple_content_length; md.content_length.value = 0; update_payload(); } @@ -572,8 +566,7 @@ on_insert_expect( "100-continue")) { md.expect.ec = - BOOST_HTTP_ERR( - error::bad_expect); + error::bad_expect; md.expect.is_100_continue = false; return; } @@ -617,8 +610,7 @@ on_insert_transfer_encoding( error: md.transfer_encoding.ec = - BOOST_HTTP_ERR( - error::bad_transfer_encoding); + error::bad_transfer_encoding; md.transfer_encoding.is_chunked = false; update_payload(); } @@ -637,8 +629,7 @@ on_insert_content_encoding( if(!rv) { md.content_encoding.ec = - BOOST_HTTP_ERR( - error::bad_content_encoding); + error::bad_content_encoding; md.content_encoding.coding = content_coding::unknown; return; @@ -694,8 +685,7 @@ on_insert_upgrade( http::version::http_1_1) { md.upgrade.ec = - BOOST_HTTP_ERR( - error::bad_upgrade); + error::bad_upgrade; md.upgrade.websocket = false; return; } @@ -704,8 +694,7 @@ on_insert_upgrade( if(! rv) { md.upgrade.ec = - BOOST_HTTP_ERR( - error::bad_upgrade); + error::bad_upgrade; md.upgrade.websocket = false; return; } @@ -1117,7 +1106,7 @@ parse_start_line( header& h, header_limits const& lim, std::size_t new_size, - system::error_code& ec) noexcept + std::error_code& ec) noexcept { BOOST_ASSERT(h.size == 0); BOOST_ASSERT(h.prefix == 0); @@ -1137,10 +1126,9 @@ parse_start_line( if(! rv) { ec = rv.error(); - if( ec == grammar::error::need_more && + if( ec == system::error_code(grammar::error::need_more) && new_size == lim.max_start_line) - ec = BOOST_HTTP_ERR( - error::start_line_limit); + ec = error::start_line_limit; return; } // method @@ -1165,8 +1153,7 @@ parse_start_line( break; default: { - ec = BOOST_HTTP_ERR( - error::bad_version); + ec = error::bad_version; return; } } @@ -1178,10 +1165,9 @@ parse_start_line( if(! rv) { ec = rv.error(); - if( ec == grammar::error::need_more && + if( ec == system::error_code(grammar::error::need_more) && new_size == lim.max_start_line) - ec = BOOST_HTTP_ERR( - error::start_line_limit); + ec = error::start_line_limit; return; } // version @@ -1197,8 +1183,7 @@ parse_start_line( break; default: { - ec = BOOST_HTTP_ERR( - error::bad_version); + ec = error::bad_version; return; } } @@ -1220,7 +1205,7 @@ parse_field( header& h, header_limits const& lim, std::size_t new_size, - system::error_code& ec) noexcept + std::error_code& ec) noexcept { if( new_size > lim.max_field) new_size = lim.max_field; @@ -1232,25 +1217,23 @@ parse_field( if(rv.has_error()) { ec = rv.error(); - if(ec == grammar::error::end_of_range) + if(ec == system::error_code(grammar::error::end_of_range)) { // final CRLF h.size = static_cast< header::offset_type>(it - h.cbuf); return; } - if( ec == grammar::error::need_more && + if( ec == system::error_code(grammar::error::need_more) && new_size == lim.max_field) { - ec = BOOST_HTTP_ERR( - error::field_size_limit); + ec = error::field_size_limit; } return; } if(h.count >= lim.max_fields) { - ec = BOOST_HTTP_ERR( - error::fields_limit); + ec = error::fields_limit; return; } if(rv->has_obs_fold) @@ -1290,7 +1273,7 @@ header:: parse( std::size_t new_size, header_limits const& lim, - system::error_code& ec) noexcept + std::error_code& ec) noexcept { if( new_size > lim.max_size) new_size = lim.max_size; @@ -1302,11 +1285,10 @@ parse( *this, lim, new_size, ec); if(ec) { - if( ec == grammar::error::need_more && + if( ec == system::error_code(grammar::error::need_more) && new_size == lim.max_fields) { - ec = BOOST_HTTP_ERR( - error::headers_limit); + ec = error::headers_limit; } return; } @@ -1317,17 +1299,16 @@ parse( *this, lim, new_size, ec); if(ec) { - if( ec == grammar::error::need_more && + if( ec == system::error_code(grammar::error::need_more) && new_size == lim.max_size) { - ec = BOOST_HTTP_ERR( - error::headers_limit); + ec = error::headers_limit; return; } break; } } - if(ec == grammar::error::end_of_range) + if(ec == system::error_code(grammar::error::end_of_range)) ec = {}; } diff --git a/src/detail/win32_unicode_path.hpp b/src/detail/win32_unicode_path.hpp index 7e8860aa..c0f9fe4f 100644 --- a/src/detail/win32_unicode_path.hpp +++ b/src/detail/win32_unicode_path.hpp @@ -28,7 +28,7 @@ class win32_unicode_path using WCHAR_ = boost::winapi::WCHAR_; public: - win32_unicode_path(const char* utf8_path, system::error_code& ec) { + win32_unicode_path(const char* utf8_path, std::error_code& ec) { int ret = mb2wide(utf8_path, static_buf_.data(), static_buf_.size()); if (ret == 0) @@ -37,7 +37,7 @@ class win32_unicode_path if (sz == 0) { ec.assign(winapi::GetLastError(), - system::system_category()); + std::system_category()); return; } dynamic_buf_.resize(sz); @@ -47,7 +47,7 @@ class win32_unicode_path if (ret2 == 0) { ec.assign(winapi::GetLastError(), - system::system_category()); + std::system_category()); return; } } diff --git a/src/detail/workspace.cpp b/src/detail/workspace.cpp index 8b68f3c9..4999abb6 100644 --- a/src/detail/workspace.cpp +++ b/src/detail/workspace.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include namespace boost { diff --git a/src/error.cpp b/src/error.cpp index 35d3bdc2..2f7aca46 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -27,16 +27,6 @@ name() const noexcept std::string error_cat_type:: message(int code) const -{ - return message(code, nullptr, 0); -} - -char const* -error_cat_type:: -message( - int code, - char*, - std::size_t) const noexcept { switch(static_cast(code)) { @@ -93,16 +83,6 @@ name() const noexcept std::string condition_cat_type:: message(int code) const -{ - return message(code, nullptr, 0); -} - -char const* -condition_cat_type:: -message( - int code, - char*, - std::size_t) const noexcept { switch(static_cast(code)) { @@ -115,7 +95,7 @@ message( bool condition_cat_type:: equivalent( - system::error_code const& ec, + std::error_code const& ec, int code) const noexcept { switch(static_cast(code)) @@ -124,7 +104,8 @@ equivalent( return (ec == error::bad_payload); case condition::need_more_input: - if( ec == urls::grammar::error::need_more || + if( ec == system::error_code( + urls::grammar::error::need_more) || ec == error::need_data ) return true; break; diff --git a/src/fields_base.cpp b/src/fields_base.cpp index c4700a78..af1bb90f 100644 --- a/src/fields_base.cpp +++ b/src/fields_base.cpp @@ -52,14 +52,13 @@ align_down( void verify_field_name( core::string_view name, - system::error_code& ec) + std::error_code& ec) { auto rv = grammar::parse( name, detail::field_name_rule); if(rv.has_error()) { - ec = BOOST_HTTP_ERR( - error::bad_field_name); + ec = error::bad_field_name; } } @@ -343,7 +342,7 @@ fields_base( op_t op(*this); op.grow(s.size(), n); s.copy(h_.buf, s.size()); - system::error_code ec; + std::error_code ec; // VFALCO This is using defaults? header_limits lim; h_.parse(s.size(), lim, ec); @@ -915,7 +914,7 @@ fields_base:: set( iterator it, core::string_view value, - system::error_code& ec) + std::error_code& ec) { auto rv = verify_field_value(value); if(rv.has_error()) @@ -1039,7 +1038,7 @@ fields_base:: set( field id, core::string_view value, - system::error_code& ec) + std::error_code& ec) { auto rv = verify_field_value(value); if(rv.has_error()) @@ -1081,7 +1080,7 @@ fields_base:: set( core::string_view name, core::string_view value, - system::error_code& ec) + std::error_code& ec) { verify_field_name(name , ec); if(ec) @@ -1133,7 +1132,7 @@ insert( core::string_view value) -> iterator { - system::error_code ec; + std::error_code ec; auto const it = insert(before, id, value, ec); if(ec) detail::throw_system_error(ec); @@ -1146,7 +1145,7 @@ insert( iterator before, field id, core::string_view value, - system::error_code& ec) + std::error_code& ec) -> iterator { insert_impl( @@ -1165,7 +1164,7 @@ insert( core::string_view value) -> iterator { - system::error_code ec; + std::error_code ec; insert(before, name, value, ec); if(ec) detail::throw_system_error(ec); @@ -1178,7 +1177,7 @@ insert( iterator before, core::string_view name, core::string_view value, - system::error_code& ec) + std::error_code& ec) -> iterator { insert_impl( @@ -1196,7 +1195,7 @@ set( iterator it, core::string_view value) { - system::error_code ec; + std::error_code ec; set(it, value, ec); if(ec) detail::throw_system_error(ec); @@ -1248,7 +1247,7 @@ insert_impl( core::string_view name, core::string_view value, std::size_t before, - system::error_code& ec) + std::error_code& ec) { verify_field_name(name, ec); if(ec) diff --git a/src/parser.cpp b/src/parser.cpp index 28b7dea7..467d310d 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -209,7 +209,7 @@ class chained_sequence std::uint64_t parse_hex( chained_sequence& cs, - system::error_code& ec) noexcept + std::error_code& ec) noexcept { std::uint64_t v = 0; std::size_t init_size = cs.size(); @@ -220,8 +220,7 @@ parse_hex( { if(init_size == cs.size()) { - ec = BOOST_HTTP_ERR( - error::bad_payload); + ec = error::bad_payload; return 0; } return v; @@ -230,23 +229,21 @@ parse_hex( // at least 4 significant bits are free if(v > (std::numeric_limits::max)() >> 4) { - ec = BOOST_HTTP_ERR( - error::bad_payload); + ec = error::bad_payload; return 0; } v = (v << 4) | static_cast(n); cs.next(); } - ec = BOOST_HTTP_ERR( - error::need_data); + ec = error::need_data; return 0; } void find_eol( chained_sequence& cs, - system::error_code& ec) noexcept + std::error_code& ec) noexcept { while(!cs.is_empty()) { @@ -256,8 +253,7 @@ find_eol( break; if(cs.value() != '\n') { - ec = BOOST_HTTP_ERR( - error::bad_payload); + ec = error::bad_payload; return; } cs.next(); @@ -265,14 +261,13 @@ find_eol( } cs.next(); } - ec = BOOST_HTTP_ERR( - error::need_data); + ec = error::need_data; } void parse_eol( chained_sequence& cs, - system::error_code& ec) noexcept + std::error_code& ec) noexcept { if(cs.size() >= 2) { @@ -282,18 +277,16 @@ parse_eol( cs.next(); return; } - ec = BOOST_HTTP_ERR( - error::bad_payload); + ec = error::bad_payload; return; } - ec = BOOST_HTTP_ERR( - error::need_data); + ec = error::need_data; } void skip_trailer_headers( chained_sequence& cs, - system::error_code& ec) noexcept + std::error_code& ec) noexcept { while(!cs.is_empty()) { @@ -303,8 +296,7 @@ skip_trailer_headers( break; if(cs.value() != '\n') { - ec = BOOST_HTTP_ERR( - error::bad_payload); + ec = error::bad_payload; return; } cs.next(); @@ -315,8 +307,7 @@ skip_trailer_headers( if(ec) return; } - ec = BOOST_HTTP_ERR( - error::need_data); + ec = error::need_data; } template @@ -342,7 +333,7 @@ class zlib_filter int window_bits) : svc_(svc) { - system::error_code ec = static_cast( + std::error_code ec = static_cast( svc_.init2(strm_, window_bits)); if(ec != http::zlib::error::ok) detail::throw_system_error(ec); @@ -425,11 +416,10 @@ class brotli_filter rv.finished = svc_.is_finished(state_); if(!more && rs == http::brotli::decoder_result::needs_more_input) - rv.ec = BOOST_HTTP_ERR(error::bad_payload); + rv.ec = error::bad_payload; if(rs == http::brotli::decoder_result::error) - rv.ec = BOOST_HTTP_ERR( - svc_.get_error_code(state_)); + rv.ec = svc_.get_error_code(state_); return rv; } @@ -853,7 +843,7 @@ class parser::impl void parse( - system::error_code& ec) + std::error_code& ec) { ec = {}; switch(state_) @@ -888,16 +878,14 @@ class parser::impl { // stream closed cleanly state_ = state::reset; - ec = BOOST_HTTP_ERR( - error::end_of_stream); + ec = error::end_of_stream; return; } // stream closed with a // partial message received state_ = state::reset; - ec = BOOST_HTTP_ERR( - error::incomplete); + ec = error::incomplete; return; } else if(ec) @@ -939,8 +927,7 @@ class parser::impl if(m_.payload() == payload::error) { // VFALCO This needs looking at - ec = BOOST_HTTP_ERR( - error::bad_payload); + ec = error::bad_payload; state_ = state::reset; // unrecoverable return; } @@ -1021,8 +1008,7 @@ class parser::impl if(!filter_ && body_limit_ < m_.payload_size()) { - ec = BOOST_HTTP_ERR( - error::body_too_large); + ec = error::body_too_large; state_ = state::reset; return; } @@ -1056,7 +1042,7 @@ class parser::impl { if(ec == condition::need_more_input && got_eof_) { - ec = BOOST_HTTP_ERR(error::incomplete); + ec = error::incomplete; state_ = state::reset; } }; @@ -1114,14 +1100,12 @@ class parser::impl { if(got_eof_) { - ec = BOOST_HTTP_ERR( - error::incomplete); + ec = error::incomplete; state_ = state::reset; return; } - ec = BOOST_HTTP_ERR( - error::need_data); + ec = error::need_data; return; } @@ -1145,8 +1129,7 @@ class parser::impl if(body_limit_remain() < chunk_avail) { - ec = BOOST_HTTP_ERR( - error::body_too_large); + ec = error::body_too_large; state_ = state::reset; return; } @@ -1163,8 +1146,7 @@ class parser::impl if(cb1_.capacity() == 0 && !chunked_body_ended) { - ec = BOOST_HTTP_ERR( - error::in_place_overflow); + ec = error::in_place_overflow; return; } @@ -1214,8 +1196,7 @@ class parser::impl { if(body_limit_remain() < payload_avail) { - ec = BOOST_HTTP_ERR( - error::body_too_large); + ec = error::body_too_large; state_ = state::reset; return; } @@ -1227,8 +1208,7 @@ class parser::impl body_total_ += payload_avail; if(cb0_.capacity() == 0 && !is_complete) { - ec = BOOST_HTTP_ERR( - error::in_place_overflow); + ec = error::in_place_overflow; return; } @@ -1241,14 +1221,12 @@ class parser::impl if(m_.payload() == payload::size && got_eof_) { - ec = BOOST_HTTP_ERR( - error::incomplete); + ec = error::incomplete; state_ = state::reset; return; } - ec = BOOST_HTTP_ERR( - error::need_data); + ec = error::need_data; return; } @@ -1370,7 +1348,7 @@ class parser::impl std::size_t apply_filter( - system::error_code& ec, + std::error_code& ec, std::size_t payload_avail, bool more) { @@ -1401,8 +1379,7 @@ class parser::impl if(cb1_.capacity() == 0 && !f_rs.finished && f_rs.in_bytes == 0) { - ec = BOOST_HTTP_ERR( - error::in_place_overflow); + ec = error::in_place_overflow; goto done; } @@ -1416,8 +1393,7 @@ class parser::impl if(body_limit_remain() == 0 && !f_rs.finished && f_rs.in_bytes == 0) { - ec = BOOST_HTTP_ERR( - error::body_too_large); + ec = error::body_too_large; state_ = state::reset; break; } @@ -1551,7 +1527,7 @@ commit_eof() void parser:: parse( - system::error_code& ec) + std::error_code& ec) { BOOST_ASSERT(impl_); impl_->parse(ec); diff --git a/src/rfc/detail/rules.cpp b/src/rfc/detail/rules.cpp index 9d14e5c4..251ae2d8 100644 --- a/src/rfc/detail/rules.cpp +++ b/src/rfc/detail/rules.cpp @@ -61,56 +61,48 @@ parse( if(it == end) { // expected "HTTP/" - BOOST_HTTP_RETURN_EC( - grammar::error::need_more); + return grammar::error::need_more; } if(end - it >= 5) { if(std::memcmp( it, "HTTP/", 5) != 0) { - BOOST_HTTP_RETURN_EC( - grammar::error::mismatch); + return grammar::error::mismatch; } it += 5; } if(it == end) { // expected DIGIT - BOOST_HTTP_RETURN_EC( - grammar::error::need_more); + return grammar::error::need_more; } if(! grammar::digit_chars(*it)) { // expected DIGIT - BOOST_HTTP_RETURN_EC( - grammar::error::need_more); + return grammar::error::need_more; } v = 10 * (*it++ - '0'); if(it == end) { // expected "." - BOOST_HTTP_RETURN_EC( - grammar::error::need_more); + return grammar::error::need_more; } if(*it != '.') { // expected "." - BOOST_HTTP_RETURN_EC( - grammar::error::need_more); + return grammar::error::need_more; } ++it; if(it == end) { // expected DIGIT - BOOST_HTTP_RETURN_EC( - grammar::error::need_more); + return grammar::error::need_more; } if(! grammar::digit_chars(*it)) { // expected DIGIT - BOOST_HTTP_RETURN_EC( - grammar::error::need_more); + return grammar::error::need_more; } v += *it++ - '0'; return v; @@ -137,16 +129,14 @@ parse( if(it == end) { // end - BOOST_HTTP_RETURN_EC( - grammar::error::need_more); + return grammar::error::need_more; } auto it0 = it; int v = dig(*it); if(v == -1) { // expected DIGIT - BOOST_HTTP_RETURN_EC( - grammar::error::mismatch); + return grammar::error::mismatch; } value_type t; t.v = 100 * v; @@ -154,30 +144,26 @@ parse( if(it == end) { // end - BOOST_HTTP_RETURN_EC( - grammar::error::need_more); + return grammar::error::need_more; } v = dig(*it); if(v == -1) { // expected DIGIT - BOOST_HTTP_RETURN_EC( - grammar::error::mismatch); + return grammar::error::mismatch; } t.v = t.v + (10 * v); ++it; if(it == end) { // end - BOOST_HTTP_RETURN_EC( - grammar::error::need_more); + return grammar::error::need_more; } v = dig(*it); if(v == -1) { // expected DIGIT - BOOST_HTTP_RETURN_EC( - grammar::error::need_more); + return grammar::error::need_more; } t.v = t.v + v; ++it; @@ -211,8 +197,7 @@ parse( system::result { if( it == end ) - BOOST_HTTP_RETURN_EC( - grammar::error::need_more); + return grammar::error::need_more; value_type v; @@ -226,7 +211,8 @@ parse( v = core::string_view(begin, it - begin); return v; } - return error::bad_field_name; + return make_error_code( + error::bad_field_name); } v = core::string_view(begin, end - begin); @@ -281,15 +267,13 @@ parse( // too short to know if we have a potential obs-fold // occurrence if( end - it < 2 ) - BOOST_HTTP_RETURN_EC( - grammar::error::need_more); + return grammar::error::need_more; if( it[1] != '\n' ) goto done; if( end - it < 3 ) - BOOST_HTTP_RETURN_EC( - grammar::error::need_more); + return grammar::error::need_more; if(! ws(it[2]) ) { @@ -339,8 +323,7 @@ parse( { if(it == end) { - BOOST_HTTP_RETURN_EC( - grammar::error::need_more); + return grammar::error::need_more; } // check for leading CRLF if(it[0] == '\r') @@ -348,18 +331,15 @@ parse( ++it; if(it == end) { - BOOST_HTTP_RETURN_EC( - grammar::error::need_more); + return grammar::error::need_more; } if(*it != '\n') { - BOOST_HTTP_RETURN_EC( - grammar::error::mismatch); + return grammar::error::mismatch; } // end of fields ++it; - BOOST_HTTP_RETURN_EC( - grammar::error::end_of_range); + return grammar::error::end_of_range; } value_type v; diff --git a/src/rfc/detail/rules.hpp b/src/rfc/detail/rules.hpp index f5e1f1cd..ef04aee1 100644 --- a/src/rfc/detail/rules.hpp +++ b/src/rfc/detail/rules.hpp @@ -128,7 +128,7 @@ struct ows_rule_t char const* end) noexcept { skip_ows(it, end); - return system::error_code(); + return std::error_code(); } }; diff --git a/src/rfc/detail/transfer_coding_rule.cpp b/src/rfc/detail/transfer_coding_rule.cpp index 4d1b21cb..f7a53b3b 100644 --- a/src/rfc/detail/transfer_coding_rule.cpp +++ b/src/rfc/detail/transfer_coding_rule.cpp @@ -35,14 +35,12 @@ transfer_parameter_rule_t::parse( if(it == end) { it = it0; - BOOST_HTTP_RETURN_EC( - grammar::error::need_more); + return grammar::error::need_more; } if(*it != ';') { it = it0; - BOOST_HTTP_RETURN_EC( - grammar::error::mismatch); + return grammar::error::mismatch; } ++it; // OWS @@ -63,14 +61,12 @@ transfer_parameter_rule_t::parse( if(it == end) { it = it0; - BOOST_HTTP_RETURN_EC( - grammar::error::need_more); + return grammar::error::need_more; } if(*it != '=') { it = it0; - BOOST_HTTP_RETURN_EC( - grammar::error::syntax); + return grammar::error::syntax; } ++it; // BWS diff --git a/src/rfc/parameter.cpp b/src/rfc/parameter.cpp index 2154ff99..f7226b5c 100644 --- a/src/rfc/parameter.cpp +++ b/src/rfc/parameter.cpp @@ -22,7 +22,7 @@ parse( { (void)it; (void)end; - return system::error_code{}; + return std::error_code{}; } } // implementation_defined } // http diff --git a/src/rfc/quoted_token_rule.cpp b/src/rfc/quoted_token_rule.cpp index 9375e0c2..9da4185b 100644 --- a/src/rfc/quoted_token_rule.cpp +++ b/src/rfc/quoted_token_rule.cpp @@ -68,8 +68,7 @@ parse( { if(it == end) { - BOOST_HTTP_RETURN_EC( - grammar::error::need_more); + return grammar::error::need_more; } if(*it != '\"') { @@ -90,27 +89,23 @@ parse( it, end, qdtext_chars); if(it == end) { - BOOST_HTTP_RETURN_EC( - grammar::error::need_more); + return grammar::error::need_more; } n += static_cast(it - it1); if(*it == '\"') break; if(*it != '\\') { - BOOST_HTTP_RETURN_EC( - grammar::error::syntax); + return grammar::error::syntax; } ++it; if(it == end) { - BOOST_HTTP_RETURN_EC( - grammar::error::need_more); + return grammar::error::need_more; } if(! qpchars(*it)) { - BOOST_HTTP_RETURN_EC( - grammar::error::syntax); + return grammar::error::syntax; } ++it; ++n; diff --git a/src/serializer.cpp b/src/serializer.cpp index 39be7c0f..20103537 100644 --- a/src/serializer.cpp +++ b/src/serializer.cpp @@ -145,7 +145,7 @@ class zlib_filter int mem_level) : svc_(svc) { - system::error_code ec = static_cast(svc_.init2( + std::error_code ec = static_cast(svc_.init2( strm_, comp_level, http::zlib::deflated, @@ -351,8 +351,7 @@ class serializer::impl needs_exp100_continue_ = false; - BOOST_HTTP_RETURN_EC( - error::expect_100_continue); + return error::expect_100_continue; } if(!filter_) @@ -364,8 +363,7 @@ class serializer::impl case style::stream: if(out_.size() == 0 && is_header_done() && more_input_) - BOOST_HTTP_RETURN_EC( - error::need_data); + return error::need_data; break; } } @@ -428,8 +426,7 @@ class serializer::impl } if(out_.size() == 0 && is_header_done() && more_input_) - BOOST_HTTP_RETURN_EC( - error::need_data); + return error::need_data; break; } } diff --git a/src/server/detail/route_match.hpp b/src/server/detail/route_match.hpp index 4d80f612..2ef48974 100644 --- a/src/server/detail/route_match.hpp +++ b/src/server/detail/route_match.hpp @@ -33,13 +33,13 @@ struct detail::router_base::matcher match_result& mr) const; // Returns error from pattern parsing, or empty if valid - system::error_code error() const noexcept { return ec_; } + std::error_code error() const noexcept { return ec_; } private: friend class detail::router_base; friend struct detail::router_base::impl; - system::error_code ec_; + std::error_code ec_; std::string allow_header_; detail::route_pattern pattern_; std::vector custom_verbs_; diff --git a/src/server/router_types.cpp b/src/server/router_types.cpp index f2585ef7..e9890cc7 100644 --- a/src/server/router_types.cpp +++ b/src/server/router_types.cpp @@ -16,16 +16,12 @@ #include #include -namespace boost { -namespace system { +namespace std { template<> struct is_error_code_enum< ::boost::http::route_what> -{ - static bool const value = true; -}; -} // system -} // boost + : std::true_type {}; +} // std namespace boost { namespace http { @@ -33,12 +29,9 @@ namespace http { namespace { struct route_what_cat_type - : system::error_category + : std::error_category { - constexpr route_what_cat_type() - : error_category(0x7a8b3c4d5e6f1029) - { - } + constexpr route_what_cat_type() noexcept = default; const char* name() const noexcept override { @@ -46,14 +39,6 @@ struct route_what_cat_type } std::string message(int code) const override - { - return message(code, nullptr, 0); - } - - char const* message( - int code, - char*, - std::size_t) const noexcept override { switch(static_cast(code)) { @@ -72,11 +57,11 @@ route_what_cat_type route_what_cat; } // (anon) -system::error_code +std::error_code make_error_code( route_what w) noexcept { - return system::error_code{ + return std::error_code{ static_cast(w), route_what_cat}; } @@ -84,10 +69,10 @@ make_error_code( route_result:: route_result( - system::error_code ec) + std::error_code ec) : ec_(ec) { - if(! ec.failed()) + if(! ec) detail::throw_invalid_argument(); } @@ -103,7 +88,7 @@ route_result:: what() const noexcept -> route_what { - if(! ec_.failed()) + if(! ec_) return route_what::done; if(&ec_.category() != &route_what_cat) return route_what::error; @@ -118,7 +103,7 @@ what() const noexcept -> auto route_result:: error() const noexcept -> - system::error_code + std::error_code { if(&ec_.category() != &route_what_cat) return ec_; diff --git a/src/server/send_file.cpp b/src/server/send_file.cpp index a53a8e6c..6fc20c5e 100644 --- a/src/server/send_file.cpp +++ b/src/server/send_file.cpp @@ -29,20 +29,20 @@ get_file_stats( std::uint64_t& size, std::uint64_t& mtime) { - system::error_code ec; + std::error_code ec; std::filesystem::path p(path.begin(), path.end()); auto status = std::filesystem::status(p, ec); - if(ec.failed() || ! std::filesystem::is_regular_file(status)) + if(ec || ! std::filesystem::is_regular_file(status)) return false; size = static_cast( std::filesystem::file_size(p, ec)); - if(ec.failed()) + if(ec) return false; auto ftime = std::filesystem::last_write_time(p, ec); - if(ec.failed()) + if(ec) return false; // Convert to Unix timestamp diff --git a/src/server/serve_static.cpp b/src/server/serve_static.cpp index d9e81397..985c6b4c 100644 --- a/src/server/serve_static.cpp +++ b/src/server/serve_static.cpp @@ -167,9 +167,9 @@ operator()(route_params& rp) const path_cat(path, impl_->root, req_path); // Check if it's a directory - system::error_code fec; + std::error_code fec; bool is_dir = std::filesystem::is_directory(path, fec); - if(is_dir && ! fec.failed()) + if(is_dir && ! fec) { // Check for trailing slash if(req_path.empty() || req_path.back() != '/') @@ -267,7 +267,7 @@ operator()(route_params& rp) const // Open and stream the file file f; - system::error_code ec; + std::error_code ec; f.open(path.c_str(), file_mode::scan, ec); if(ec) { @@ -284,7 +284,7 @@ operator()(route_params& rp) const if(info.is_range && info.range_start > 0) { f.seek(static_cast(info.range_start), ec); - if(ec.failed()) + if(ec) { rp.res.set_status(status::internal_server_error); auto [ec2] = co_await rp.send("Internal Server Error"); @@ -315,7 +315,7 @@ operator()(route_params& rp) const static_cast(bufs[0].size()))); auto const n1 = f.read(bufs[0].data(), to_read, ec); - if(ec.failed()) + if(ec) co_return route_error(ec); if(n1 == 0) break; diff --git a/src/zlib/error.cpp b/src/zlib/error.cpp index d09599cf..019c8a0d 100644 --- a/src/zlib/error.cpp +++ b/src/zlib/error.cpp @@ -21,26 +21,9 @@ name() const noexcept return "boost.http.zlib"; } -bool -error_cat_type:: -failed(int ev) const noexcept -{ - return ev < 0; -} - std::string error_cat_type:: message(int ev) const -{ - return message(ev, nullptr, 0); -} - -char const* -error_cat_type:: -message( - int ev, - char*, - std::size_t) const noexcept { switch(static_cast(ev)) { diff --git a/src/zstd/error.cpp b/src/zstd/error.cpp index 4bcb9bc1..873dc1be 100644 --- a/src/zstd/error.cpp +++ b/src/zstd/error.cpp @@ -21,26 +21,9 @@ name() const noexcept return "boost.http.zstd"; } -bool -error_cat_type:: -failed(int ev) const noexcept -{ - return ev != 0; -} - std::string error_cat_type:: message(int ev) const -{ - return message(ev, nullptr, 0); -} - -char const* -error_cat_type:: -message( - int ev, - char*, - std::size_t) const noexcept { switch(static_cast(ev)) { diff --git a/test/unit/bcrypt.cpp b/test/unit/bcrypt.cpp index 3a74f863..ed86fa33 100644 --- a/test/unit/bcrypt.cpp +++ b/test/unit/bcrypt.cpp @@ -96,14 +96,14 @@ struct bcrypt_test test_error_code() { // Test error codes can be created - system::error_code ec1 = bcrypt::make_error_code(bcrypt::error::ok); + std::error_code ec1 = bcrypt::make_error_code(bcrypt::error::ok); BOOST_TEST(! ec1); - system::error_code ec2 = bcrypt::make_error_code(bcrypt::error::invalid_salt); + std::error_code ec2 = bcrypt::make_error_code(bcrypt::error::invalid_salt); BOOST_TEST(ec2); BOOST_TEST(ec2.message() == "invalid salt"); - system::error_code ec3 = bcrypt::make_error_code(bcrypt::error::invalid_hash); + std::error_code ec3 = bcrypt::make_error_code(bcrypt::error::invalid_hash); BOOST_TEST(ec3); BOOST_TEST(ec3.message() == "invalid hash"); } @@ -174,7 +174,7 @@ struct bcrypt_test // Generate salt, then hash { - system::error_code ec; + std::error_code ec; bcrypt::result h = bcrypt::hash("password", salt.str(), ec); BOOST_TEST(! ec); BOOST_TEST(h.size() == 60); @@ -182,11 +182,11 @@ struct bcrypt_test // Same password + salt = same hash { - system::error_code ec1; + std::error_code ec1; bcrypt::result hash1 = bcrypt::hash("password", salt.str(), ec1); BOOST_TEST(! ec1); - system::error_code ec2; + std::error_code ec2; bcrypt::result hash2 = bcrypt::hash("password", salt.str(), ec2); BOOST_TEST(! ec2); @@ -195,7 +195,7 @@ struct bcrypt_test // Invalid salt { - system::error_code ec; + std::error_code ec; bcrypt::result h = bcrypt::hash("password", "invalid", ec); BOOST_TEST(ec == bcrypt::error::invalid_salt); BOOST_TEST(h.empty()); @@ -203,7 +203,7 @@ struct bcrypt_test // Malformed salt { - system::error_code ec; + std::error_code ec; bcrypt::result h = bcrypt::hash("password", "$2b$04$", ec); BOOST_TEST(ec == bcrypt::error::invalid_salt); BOOST_TEST(h.empty()); @@ -217,7 +217,7 @@ struct bcrypt_test // Correct password { - system::error_code ec; + std::error_code ec; bool match = bcrypt::compare("correct_password", r.str(), ec); BOOST_TEST(! ec); BOOST_TEST(match); @@ -225,7 +225,7 @@ struct bcrypt_test // Wrong password { - system::error_code ec; + std::error_code ec; bool match = bcrypt::compare("wrong_password", r.str(), ec); BOOST_TEST(! ec); BOOST_TEST(! match); @@ -233,7 +233,7 @@ struct bcrypt_test // Empty password (should not match) { - system::error_code ec; + std::error_code ec; bool match = bcrypt::compare("", r.str(), ec); BOOST_TEST(! ec); BOOST_TEST(! match); @@ -241,7 +241,7 @@ struct bcrypt_test // Invalid hash { - system::error_code ec; + std::error_code ec; bool match = bcrypt::compare("password", "invalid", ec); BOOST_TEST(ec == bcrypt::error::invalid_hash); BOOST_TEST(! match); @@ -249,7 +249,7 @@ struct bcrypt_test // Malformed hash (wrong length) { - system::error_code ec; + std::error_code ec; bool match = bcrypt::compare("password", "$2b$04$abcdefghij", ec); BOOST_TEST(ec == bcrypt::error::invalid_hash); BOOST_TEST(! match); @@ -261,7 +261,7 @@ struct bcrypt_test { // Valid hash { - system::error_code ec; + std::error_code ec; unsigned rounds = bcrypt::get_rounds( "$2b$12$abcdefghijklmnopqrstuuxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", ec); BOOST_TEST(! ec); @@ -270,7 +270,7 @@ struct bcrypt_test // Different versions { - system::error_code ec; + std::error_code ec; unsigned rounds = bcrypt::get_rounds( "$2a$10$abcdefghijklmnopqrstuuxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", ec); BOOST_TEST(! ec); @@ -279,7 +279,7 @@ struct bcrypt_test // Invalid format { - system::error_code ec; + std::error_code ec; unsigned rounds = bcrypt::get_rounds("invalid", ec); BOOST_TEST(ec == bcrypt::error::invalid_hash); BOOST_TEST(rounds == 0); @@ -287,7 +287,7 @@ struct bcrypt_test // Missing prefix { - system::error_code ec; + std::error_code ec; unsigned rounds = bcrypt::get_rounds("2b$10$abc", ec); BOOST_TEST(ec == bcrypt::error::invalid_hash); BOOST_TEST(rounds == 0); @@ -301,7 +301,7 @@ struct bcrypt_test // U*U with all-C salt { - system::error_code ec; + std::error_code ec; BOOST_TEST(bcrypt::compare("U*U", "$2a$05$CCCCCCCCCCCCCCCCCCCCC.E5YPO9kmyuRGyh0XouQYb4YMJKvyOeW", ec)); BOOST_TEST(! ec); @@ -309,7 +309,7 @@ struct bcrypt_test // Empty password { - system::error_code ec; + std::error_code ec; BOOST_TEST(bcrypt::compare("", "$2a$06$DCq7YPn5Rq63x1Lad4cll.TV4S6ytwfsfvkgY8jIucDrjc8deX1s.", ec)); BOOST_TEST(! ec); @@ -317,7 +317,7 @@ struct bcrypt_test // Test that wrong password fails { - system::error_code ec; + std::error_code ec; BOOST_TEST(! bcrypt::compare("wrong", "$2a$05$CCCCCCCCCCCCCCCCCCCCC.E5YPO9kmyuRGyh0XouQYb4YMJKvyOeW", ec)); BOOST_TEST(! ec); @@ -333,11 +333,11 @@ struct bcrypt_test bcrypt::result salt = bcrypt::gen_salt(4); - system::error_code ec1; + std::error_code ec1; bcrypt::result r1 = bcrypt::hash(long_pw, salt.str(), ec1); BOOST_TEST(! ec1); - system::error_code ec2; + std::error_code ec2; bcrypt::result r2 = bcrypt::hash(truncated_pw, salt.str(), ec2); BOOST_TEST(! ec2); diff --git a/test/unit/brotli.cpp b/test/unit/brotli.cpp index aeca0efb..b303edeb 100644 --- a/test/unit/brotli.cpp +++ b/test/unit/brotli.cpp @@ -31,7 +31,7 @@ struct brotli_test test_error_code() { // TODO - boost::system::error_code ec{ brotli::error::no_error }; + std::error_code ec{ brotli::error::no_error }; } void diff --git a/test/unit/error.cpp b/test/unit/error.cpp index 65927da1..5370028a 100644 --- a/test/unit/error.cpp +++ b/test/unit/error.cpp @@ -48,7 +48,7 @@ class error_test check( std::string name, condition c, - system::error_code ec) + std::error_code ec) { { BOOST_TEST_NE( @@ -111,7 +111,8 @@ class error_test check(n, condition::need_more_input, - urls::grammar::error::need_more); + system::error_code( + urls::grammar::error::need_more)); check(n, condition::invalid_payload, error::bad_payload); diff --git a/test/unit/fields_base.cpp b/test/unit/fields_base.cpp index f2be171f..f36cc4d2 100644 --- a/test/unit/fields_base.cpp +++ b/test/unit/fields_base.cpp @@ -415,7 +415,7 @@ struct fields_base_test { BOOST_TEST_THROWS( f.append(field::server, "bad\r\nvalue"), - system::system_error); + std::system_error); }, "\r\n"); @@ -508,14 +508,14 @@ struct fields_base_test "\r\n", [](fields_base& f) { - system::error_code ec; + std::error_code ec; // ends with invalid obs-fold f.append("X", "AB\r\n C \r\n", ec); BOOST_TEST(ec == error::bad_field_value); BOOST_TEST_THROWS( f.append("X", "AB\r\n C \r\n"), - system::system_error); + std::system_error); // contains invalid obs-fold between {AB, C} ec = {}; @@ -578,7 +578,7 @@ struct fields_base_test [](fields_base& f) { { - system::error_code ec; + std::error_code ec; auto it = f.insert(f.find("T"), field::server, "x", ec); BOOST_TEST(!ec); BOOST_TEST(it == f.find(field::server)); @@ -600,7 +600,7 @@ struct fields_base_test [](fields_base& f) { { - system::error_code ec; + std::error_code ec; auto pos = f.find("T"); auto it = f.insert(f.find("U"), field::server, "x", ec); BOOST_TEST(!ec); @@ -626,12 +626,12 @@ struct fields_base_test "\r\n", [](fields_base& f) { - system::error_code ec; + std::error_code ec; f.insert(f.find("U"), field::server, "a\r\nb", ec); BOOST_TEST(ec); BOOST_TEST_THROWS( f.insert(f.find("U"), field::server, "a\r\nb"), - system::system_error); + std::system_error); }); // insert(iterator, string_view, string_view) @@ -670,13 +670,13 @@ struct fields_base_test "\r\n", [](fields_base& f) { - system::error_code ec; + std::error_code ec; f.insert(f.find("U"), "Ser ver", "x", ec); BOOST_TEST(ec == error::bad_field_name); BOOST_TEST_THROWS( f.insert(f.find("U"), "Ser ver", "x"), - system::system_error); + std::system_error); ec = {}; f.insert(f.find("U"), " Server", "x", ec); @@ -935,7 +935,7 @@ struct fields_base_test [](fields_base& f) { f.set(f.find("T"), "2"); - system::error_code ec; + std::error_code ec; f.set(f.find("T"), "2", ec); BOOST_TEST(!ec); }, @@ -977,12 +977,12 @@ struct fields_base_test "\r\n", [](fields_base& f) { - system::error_code ec; + std::error_code ec; f.set(f.find("T"), "\r\n", ec); BOOST_TEST_EQ(ec, error::bad_field_value); BOOST_TEST_THROWS( f.set(f.find("T"), "\r\n"), - system::system_error); + std::system_error); ec = {}; f.set( @@ -994,7 +994,7 @@ struct fields_base_test f.set( f.find("T"), "abcdefghijk\r\nlmnopqrstuvwxyz"), - system::system_error); + std::system_error); }); // set(field, string_view) @@ -1004,7 +1004,7 @@ struct fields_base_test [](fields_base& f) { f.set(field::server, "x"); - system::error_code ec; + std::error_code ec; f.set(field::server, "x"); BOOST_TEST(!ec); }, @@ -1055,7 +1055,7 @@ struct fields_base_test [](fields_base& f) { f.set(field::server, "\r\n x\r\n yz \r\n \r\n\t"); - system::error_code ec; + std::error_code ec; f.set(field::server, "\r\n x\r\n yz \r\n \r\n\t", ec); BOOST_TEST(!ec); }, @@ -1067,19 +1067,19 @@ struct fields_base_test "\r\n", [](fields_base& f) { - system::error_code ec; + std::error_code ec; f.set(field::server, "\r\n x\r\nyz \r\n \r\n\t", ec); BOOST_TEST_EQ(ec, error::bad_field_smuggle); BOOST_TEST_THROWS( f.set(field::server, "\r\n x\r\nyz \r\n \r\n\t"), - system::system_error); + std::system_error); ec = {}; f.set(field::server, "yz\r\n\x01\x02\x03", ec); BOOST_TEST_EQ(ec, error::bad_field_smuggle); BOOST_TEST_THROWS( f.set(field::server, "yz\r\n\x01\x02\x03"), - system::system_error); + std::system_error); }); // set(string_view, string_view) @@ -1173,33 +1173,33 @@ struct fields_base_test "\r\n", [](fields_base& f) { - system::error_code ec; + std::error_code ec; f.set(" invalid string", "valid string", ec); BOOST_TEST_EQ(ec, error::bad_field_name); BOOST_TEST_THROWS( f.set(" invalid string", "valid string"), - system::system_error); + std::system_error); ec = {}; f.set("invalid\r\n string", "valid string", ec); BOOST_TEST_EQ(ec, error::bad_field_name); BOOST_TEST_THROWS( f.set("invalid\r\n string", "valid string"), - system::system_error); + std::system_error); ec = {}; f.set("valid", "\r\ninvalid string", ec); BOOST_TEST_EQ(ec, error::bad_field_smuggle); BOOST_TEST_THROWS( f.set("valid", "\r\ninvalid string"), - system::system_error); + std::system_error); ec = {}; f.set("valid", "invalid\x01\x02\r\nstring", ec); BOOST_TEST_EQ(ec, error::bad_field_value); BOOST_TEST_THROWS( f.set("valid", "\r\ninvalid string"), - system::system_error); + std::system_error); }); } @@ -1264,7 +1264,7 @@ struct fields_base_test response const res(s); BOOST_TEST_EQ( res.metadata().expect.ec, - system::error_code()); + std::error_code()); BOOST_TEST_EQ( res.metadata().expect.count, res.count(field::expect)); diff --git a/test/unit/file.cpp b/test/unit/file.cpp index c79a5a04..5aaace8b 100644 --- a/test/unit/file.cpp +++ b/test/unit/file.cpp @@ -11,7 +11,7 @@ // Test that header file is self-contained. #include -#include +#include #include "file_test.hpp" namespace boost { @@ -25,32 +25,32 @@ struct file_test // constructor BOOST_TEST_THROWS( file("missing.txt", file_mode::scan), - system::system_error); + std::system_error); file f; char buf[1]; BOOST_TEST_THROWS( f.open("missing.txt", file_mode::scan), - system::system_error); + std::system_error); // BOOST_TEST_THROWS( // f.close(), - // system::system_error); + // std::system_error); BOOST_TEST_THROWS( f.size(), - system::system_error); + std::system_error); BOOST_TEST_THROWS( f.pos(), - system::system_error); + std::system_error); BOOST_TEST_THROWS( f.seek(1), - system::system_error); + std::system_error); BOOST_TEST_THROWS( f.read(buf, 1), - system::system_error); + std::system_error); BOOST_TEST_THROWS( f.write(buf, 1), - system::system_error); + std::system_error); } void diff --git a/test/unit/file_test.hpp b/test/unit/file_test.hpp index eb261114..e9b3a993 100644 --- a/test/unit/file_test.hpp +++ b/test/unit/file_test.hpp @@ -138,34 +138,34 @@ test_file() BOOST_TEST(! f.is_open()); BOOST_TEST(! fs::exists(path)); { - system::error_code ec; + std::error_code ec; f.size(ec); BOOST_TEST(ec == - system::errc::bad_file_descriptor); + std::errc::bad_file_descriptor); } { - system::error_code ec; + std::error_code ec; f.pos(ec); BOOST_TEST(ec == - system::errc::bad_file_descriptor); + std::errc::bad_file_descriptor); } { - system::error_code ec; + std::error_code ec; f.seek(0, ec); BOOST_TEST(ec == - system::errc::bad_file_descriptor); + std::errc::bad_file_descriptor); } { - system::error_code ec; + std::error_code ec; f.read(buf, 0, ec); BOOST_TEST(ec == - system::errc::bad_file_descriptor); + std::errc::bad_file_descriptor); } { - system::error_code ec; + std::error_code ec; f.write(buf, 0, ec); BOOST_TEST(ec == - system::errc::bad_file_descriptor); + std::errc::bad_file_descriptor); } } @@ -173,7 +173,7 @@ test_file() { { File f; - system::error_code ec; + std::error_code ec; create(path); f.open(path, file_mode::read, ec); BOOST_TEST(! ec); @@ -185,7 +185,7 @@ test_file() { { File f; - system::error_code ec; + std::error_code ec; create(path); f.open(path, file_mode::scan, ec); BOOST_TEST(! ec); @@ -197,7 +197,7 @@ test_file() { { File f; - system::error_code ec; + std::error_code ec; BOOST_TEST(! fs::exists(path)); f.open(path, file_mode::write, ec); BOOST_TEST(! ec); @@ -205,7 +205,7 @@ test_file() } { File f; - system::error_code ec; + std::error_code ec; BOOST_TEST(fs::exists(path)); f.open(path, file_mode::write, ec); BOOST_TEST(! ec); @@ -218,7 +218,7 @@ test_file() { { File f; - system::error_code ec; + std::error_code ec; BOOST_TEST(! fs::exists(path)); f.open(path, file_mode::write_new, ec); BOOST_TEST(! ec); @@ -226,7 +226,7 @@ test_file() } { File f; - system::error_code ec; + std::error_code ec; BOOST_TEST(fs::exists(path)); f.open(path, file_mode::write_new, ec); BOOST_TEST(ec); @@ -238,7 +238,7 @@ test_file() { { File f; - system::error_code ec; + std::error_code ec; BOOST_TEST(! fs::exists(path)); f.open(path, file_mode::write_existing, ec); BOOST_TEST(ec); @@ -246,7 +246,7 @@ test_file() } { File f; - system::error_code ec; + std::error_code ec; create(path); BOOST_TEST(fs::exists(path)); f.open(path, file_mode::write_existing, ec); @@ -259,7 +259,7 @@ test_file() { { File f; - system::error_code ec; + std::error_code ec; BOOST_TEST(! fs::exists(path)); f.open(path, file_mode::append, ec); BOOST_TEST(! ec); @@ -274,7 +274,7 @@ test_file() { File f; - system::error_code ec; + std::error_code ec; BOOST_TEST(fs::exists(path)); f.open(path, file_mode::append, ec); BOOST_TEST(! ec); @@ -293,7 +293,7 @@ test_file() { { File f; - system::error_code ec; + std::error_code ec; BOOST_TEST(! fs::exists(path)); f.open(path, file_mode::append_existing, ec); BOOST_TEST(ec); @@ -302,7 +302,7 @@ test_file() remove(path); { File f; - system::error_code ec; + std::error_code ec; create(path, "the cat"); f.open(path, file_mode::append_existing, ec); BOOST_TEST(! ec); @@ -321,7 +321,7 @@ test_file() { { File f1; - system::error_code ec; + std::error_code ec; f1.open(path, file_mode::write, ec); BOOST_TEST(! ec); BOOST_TEST(f1.is_open()); @@ -344,7 +344,7 @@ test_file() { { File f; - system::error_code ec; + std::error_code ec; f.open(path, file_mode::write, ec); BOOST_TEST(! ec); f.open(path, file_mode::write, ec); @@ -357,7 +357,7 @@ test_file() { temp_path path2; { - system::error_code ec; + std::error_code ec; File f1; f1.open(path, file_mode::write, ec); @@ -379,7 +379,7 @@ test_file() { { File f; - system::error_code ec; + std::error_code ec; f.open(path, file_mode::write, ec); BOOST_TEST(! ec); auto& f_(f); @@ -394,7 +394,7 @@ test_file() { File f; auto none = f.native_handle(); - system::error_code ec; + std::error_code ec; f.open(path, file_mode::write, ec); BOOST_TEST(! ec); auto fd = f.native_handle(); @@ -413,7 +413,7 @@ test_file() // write { File f; - system::error_code ec; + std::error_code ec; f.open(path, file_mode::write, ec); BOOST_TEST(! ec); @@ -435,7 +435,7 @@ test_file() // read { File f; - system::error_code ec; + std::error_code ec; f.open(path, file_mode::read, ec); BOOST_TEST(! ec); diff --git a/test/unit/metadata.cpp b/test/unit/metadata.cpp index b941738c..f03b945d 100644 --- a/test/unit/metadata.cpp +++ b/test/unit/metadata.cpp @@ -25,7 +25,7 @@ namespace http { struct metadata_test { - system::error_code const ok{}; + std::error_code const ok{}; // make sure that subrange correctly // uses the count information in diff --git a/test/unit/parser.cpp b/test/unit/parser.cpp index d110c30a..d540838b 100644 --- a/test/unit/parser.cpp +++ b/test/unit/parser.cpp @@ -198,7 +198,7 @@ struct parser_test read_some( parser& pr, pieces& in, - system::error_code& ec) + std::error_code& ec) { pr.parse(ec); if(ec != condition::need_more_input) @@ -228,7 +228,7 @@ struct parser_test read_header( parser& pr, pieces& in, - system::error_code& ec) + std::error_code& ec) { do { @@ -246,7 +246,7 @@ struct parser_test read( parser& pr, pieces& in, - system::error_code& ec) + std::error_code& ec) { do { @@ -274,7 +274,7 @@ struct parser_test s.data(), s.size())); pr.commit(n); BOOST_TEST_EQ(n, s.size()); - system::error_code ec; + std::error_code ec; pr.parse(ec); if( ec == condition::need_more_input) ec = {}; @@ -312,7 +312,7 @@ struct parser_test request_parser pr1(req_cfg_); pr1.reset(); pr1.start(); - system::error_code ec; + std::error_code ec; read_header(pr1, in, ec); BOOST_TEST_NOT(ec); @@ -460,7 +460,7 @@ struct parser_test core::string_view s) { auto pcfg = make_parser_config(cfg); - system::error_code ec; + std::error_code ec; request_parser pr(pcfg); pr.reset(); pr.start(); @@ -504,7 +504,7 @@ struct parser_test pieces in({ "GET / HTTP/1.1\r\n\r\n"}); auto pcfg = make_parser_config(cfg); - system::error_code ec; + std::error_code ec; request_parser pr(pcfg); pr.reset(); pr.start(); @@ -595,7 +595,7 @@ struct parser_test request_parser pr(req_cfg_); pr.reset(); pr.start(); - system::error_code ec; + std::error_code ec; pieces in = { "POST / HTTP/1.1\r\n" "Content-Length: 5\r\n" @@ -630,12 +630,12 @@ struct parser_test auto const check_in_place = []( parser_config const& cfg, - system::error_code ex, + std::error_code ex, bool is_complete, pieces&& in) { auto pcfg = make_parser_config(cfg); - system::error_code ec; + std::error_code ec; response_parser pr(pcfg); pr.reset(); pr.start(); @@ -701,7 +701,7 @@ struct parser_test request_parser pr(req_cfg_); pr.reset(); pr.start(); - system::error_code ec; + std::error_code ec; pieces in = { "GET / HTTP/1.1\r\n" "Content-Length: 1\r\n" @@ -722,7 +722,7 @@ struct parser_test request_parser pr(req_cfg_); pr.reset(); pr.start(); - system::error_code ec; + std::error_code ec; pieces in = { "GET / HTTP/1.1\r\n" "Content-Length: 1\r\n" @@ -777,7 +777,7 @@ struct parser_test response_parser pr(res_cfg_); pr.reset(); pr.start(); - system::error_code ec; + std::error_code ec; pieces in = { "HTTP/1.1 200 OK\r\n" "\r\n" }; @@ -796,7 +796,7 @@ struct parser_test request_parser pr(req_cfg_); pr.reset(); pr.start(); - system::error_code ec; + std::error_code ec; pieces in = { "GET / HTTP/1.1\r\n" "\r\n" }; @@ -815,7 +815,7 @@ struct parser_test { // missing reset request_parser pr(req_cfg_); - system::error_code ec; + std::error_code ec; BOOST_TEST_THROWS( pr.parse(ec), std::logic_error); @@ -825,7 +825,7 @@ struct parser_test // missing start request_parser pr(req_cfg_); pr.reset(); - system::error_code ec; + std::error_code ec; BOOST_TEST_THROWS( pr.parse(ec), std::logic_error); @@ -838,12 +838,12 @@ struct parser_test auto const check_in_place2 = []( parser_config const& cfg, bool some, - system::error_code ex, + std::error_code ex, bool is_complete, pieces&& in) { auto pcfg = make_parser_config(cfg); - system::error_code ec; + std::error_code ec; response_parser pr(pcfg); pr.reset(); pr.start(); @@ -966,9 +966,9 @@ struct parser_test void check_in_place( pieces& in, - system::error_code ex = {}) + std::error_code ex = {}) { - system::error_code ec; + std::error_code ec; start(); read_header(*pr_, in, ec); @@ -1006,7 +1006,7 @@ struct parser_test void check_req_1( pieces const& in0, - system::error_code ex) + std::error_code ex) { auto in = in0; check_in_place(in, ex); @@ -1015,7 +1015,7 @@ struct parser_test void check_res_1( pieces const& in0, - system::error_code ex) + std::error_code ex) { auto in = in0; check_in_place(in, ex); @@ -1078,7 +1078,7 @@ struct parser_test check_req( core::string_view sh, core::string_view sb, - system::error_code ex = {}) + std::error_code ex = {}) { pr_ = &req_pr_; grind(sh, sb, [&]( @@ -1092,7 +1092,7 @@ struct parser_test check_res( core::string_view sh, core::string_view sb, - system::error_code ex = {}) + std::error_code ex = {}) { pr_ = &res_pr_; grind(sh, sb, [&]( @@ -1116,7 +1116,7 @@ struct parser_test void should_fail( - system::error_code ex, + std::error_code ex, core::string_view sh, core::string_view sb) { @@ -1235,7 +1235,7 @@ struct parser_test "d\r\nhello, world!\r\n" "0\r\n\r\n" }; - system::error_code ec; + std::error_code ec; read(pr, in, ec); BOOST_TEST(! ec); BOOST_TEST(pr.is_complete()); @@ -1264,7 +1264,7 @@ struct parser_test "hello, world!\r\n" "0\r\n\r\n" }; - system::error_code ec; + std::error_code ec; read_header(pr, in1, ec); BOOST_TEST(! ec); BOOST_TEST(pr.got_header()); @@ -1294,7 +1294,7 @@ struct parser_test "1234\r\nhello, world!\r\n" "0\r\n\r\n" }; - system::error_code ec; + std::error_code ec; read_header(pr, in1, ec); BOOST_TEST(! ec); BOOST_TEST(pr.got_header()); @@ -1322,7 +1322,7 @@ struct parser_test "03\r\nhello, world!\r\n" "0\r\n\r\n" }; - system::error_code ec; + std::error_code ec; read_header(pr, in1, ec); BOOST_TEST(! ec); BOOST_TEST(pr.got_header()); @@ -1351,7 +1351,7 @@ struct parser_test "0\r\n\r\n" }; - system::error_code ec; + std::error_code ec; read(pr, in, ec); BOOST_TEST(pr.is_complete()); BOOST_TEST( @@ -1387,7 +1387,7 @@ struct parser_test pieces in = { headers, bad_chunk }; - system::error_code ec; + std::error_code ec; read_header(pr, in, ec); BOOST_TEST(! ec); BOOST_TEST(pr.got_header()); @@ -1429,7 +1429,7 @@ struct parser_test body.substr(0, i), body.substr(i) }; - system::error_code ec; + std::error_code ec; read_header(pr, in, ec); BOOST_TEST(! ec); BOOST_TEST(pr.got_header()); @@ -1456,7 +1456,7 @@ struct parser_test cfg.min_buffer = 500; auto pcfg = make_parser_config(cfg); - system::error_code ec; + std::error_code ec; request_parser pr(pcfg); @@ -1566,7 +1566,7 @@ struct parser_test cfg.headers.max_size = 500; auto pcfg = make_parser_config(cfg); - system::error_code ec; + std::error_code ec; request_parser pr(pcfg); pr.reset(); @@ -1667,7 +1667,7 @@ struct parser_test "content-length: 7\r\n" "\r\n" "1234567" }; - system::error_code ec; + std::error_code ec; read_header(pr, in, ec); BOOST_TEST(! ec); BOOST_TEST(pr.got_header()); @@ -1687,7 +1687,7 @@ struct parser_test "content-length: 7\r\n" "\r\n" "1234567" }; - system::error_code ec; + std::error_code ec; read_header(pr, in, ec); BOOST_TEST(! ec); BOOST_TEST(pr.got_header()); @@ -1711,7 +1711,7 @@ struct parser_test "HTTP/1.1 200 OK\r\n" "content-length: 0\r\n" "\r\n" }; - system::error_code ec; + std::error_code ec; read_header(pr, in, ec); BOOST_TEST(! ec); BOOST_TEST(pr.got_header()); @@ -1737,7 +1737,7 @@ struct parser_test "transfer-encoding: chunked\r\n" "\r\n" "bad-chunk-header\r\n" }; - system::error_code ec; + std::error_code ec; read_header(pr, in, ec); BOOST_TEST(! ec); BOOST_TEST(pr.got_header()); @@ -1768,7 +1768,7 @@ struct parser_test capy::const_buffer( octets.data(), octets.size()))); - system::error_code ec; + std::error_code ec; pr.parse(ec); BOOST_TEST(! ec); BOOST_TEST(pr.got_header()); @@ -1814,7 +1814,7 @@ struct parser_test capy::const_buffer( octets.data(), octets.size()))); - system::error_code ec; + std::error_code ec; pr.parse(ec); BOOST_TEST(! ec); BOOST_TEST(pr.got_header()); @@ -1877,7 +1877,7 @@ struct parser_test pr.prepare(), capy::const_buffer( octets.data(), octets.size()))); - system::error_code ec; + std::error_code ec; pr.parse(ec); BOOST_TEST(pr.got_header()); pr.parse(ec); diff --git a/test/unit/request_parser.cpp b/test/unit/request_parser.cpp index 4421929b..dadc07bc 100644 --- a/test/unit/request_parser.cpp +++ b/test/unit/request_parser.cpp @@ -39,7 +39,7 @@ struct request_parser_test s.data(), n); pr.commit(n); s.remove_prefix(n); - system::error_code ec; + std::error_code ec; pr.parse(ec); if(ec == error::end_of_message || ! ec) @@ -75,7 +75,7 @@ struct request_parser_test s.data(), n); pr.commit(n); s.remove_prefix(n); - system::error_code ec; + std::error_code ec; pr.parse(ec); if(ec == condition::need_more_input) continue; @@ -147,7 +147,7 @@ struct request_parser_test std::memcpy( b.data(), s.data(), n); pr.commit(n); - system::error_code ec; + std::error_code ec; pr.parse(ec); BOOST_TEST(! ec); //BOOST_TEST(pr.is_done()); @@ -170,7 +170,7 @@ struct request_parser_test std::memcpy( b.data(), s.data(), n); pr.commit(n); - system::error_code ec; + std::error_code ec; pr.parse(ec); if(! BOOST_TEST( ec == condition::need_more_input)) diff --git a/test/unit/serializer.cpp b/test/unit/serializer.cpp index 76fce169..6726c5a6 100644 --- a/test/unit/serializer.cpp +++ b/test/unit/serializer.cpp @@ -701,7 +701,7 @@ struct serializer_test { auto cbs = sr.prepare(); BOOST_TEST_EQ( - cbs.error(), + std::error_code(cbs.error()), error::need_data); } @@ -711,7 +711,7 @@ struct serializer_test sr.stream_commit(0); auto cbs = sr.prepare(); BOOST_TEST_EQ( - cbs.error(), + std::error_code(cbs.error()), error::need_data); } diff --git a/test/unit/server/router.cpp b/test/unit/server/router.cpp index ecccea2e..6393da07 100644 --- a/test/unit/server/router.cpp +++ b/test/unit/server/router.cpp @@ -59,30 +59,30 @@ struct router_test { co_return route_next_route; } // returns specified error - static auto h_fail(system::error_code ec) + static auto h_fail(std::error_code ec) { return [ec](params&) -> route_task { co_return route_error(ec); }; } // error handler returns success - static auto eh_send(system::error_code expect) + static auto eh_send(std::error_code expect) { - return [expect](params&, system::error_code ec) -> route_task + return [expect](params&, std::error_code ec) -> route_task { BOOST_TEST(ec == expect); co_return route_result{}; }; } // error handler returns route_next - static auto eh_next(system::error_code expect) + static auto eh_next(std::error_code expect) { - return [expect](params&, system::error_code ec) -> route_task + return [expect](params&, std::error_code ec) -> route_task { BOOST_TEST(ec == expect); co_return route_next; }; } // error handler returns a new error - static auto eh_return(system::error_code new_ec) + static auto eh_return(std::error_code new_ec) { - return [new_ec](params&, system::error_code) -> route_task + return [new_ec](params&, std::error_code) -> route_task { co_return route_error(new_ec); }; } @@ -224,8 +224,8 @@ struct router_test void testError() { - system::error_code const er = http::error::bad_connection; - system::error_code const er2 = http::error::bad_expect; + std::error_code const er = http::error::bad_connection; + std::error_code const er2 = http::error::bad_expect; // error from handler { test_router r; r.use(h_fail(er)); check(r, "/", route_error(er)); } @@ -337,7 +337,7 @@ struct router_test // error propagates from nested { - system::error_code const er = http::error::bad_connection; + std::error_code const er = http::error::bad_connection; test_router r; r.use("/api", [er]{ test_router r2; diff --git a/test/unit/test_helpers.hpp b/test/unit/test_helpers.hpp index d2ca5420..7455a055 100644 --- a/test/unit/test_helpers.hpp +++ b/test/unit/test_helpers.hpp @@ -119,7 +119,7 @@ typename std::enable_if< bad( R const& r, core::string_view s, - system::error_code const& e) + std::error_code const& e) { auto rv = grammar::parse(s, r); if(BOOST_TEST(rv.has_error())) diff --git a/test/unit/zlib.cpp b/test/unit/zlib.cpp index 60942a77..4e51c0f5 100644 --- a/test/unit/zlib.cpp +++ b/test/unit/zlib.cpp @@ -31,7 +31,7 @@ struct zlib_test test_error_code() { // TODO - boost::system::error_code ec{ zlib::error::buf_err }; + std::error_code ec{ zlib::error::buf_err }; } void diff --git a/test/unit/zstd.cpp b/test/unit/zstd.cpp index a5473523..8acc075a 100644 --- a/test/unit/zstd.cpp +++ b/test/unit/zstd.cpp @@ -33,18 +33,18 @@ struct zstd_test void test_error_code() { - system::error_code ec = zstd::error::no_error; + std::error_code ec = zstd::error::no_error; + BOOST_TEST(! ec); BOOST_TEST(! ec); - BOOST_TEST(! ec.failed()); BOOST_TEST_EQ(std::string(ec.category().name()), std::string("boost.http.zstd")); ec = zstd::error::corruption_detected; - BOOST_TEST(ec.failed()); + BOOST_TEST(ec); BOOST_TEST(ec == zstd::error::corruption_detected); BOOST_TEST_EQ(ec.message(), "corruption_detected"); ec = static_cast(9999); - BOOST_TEST(ec.failed()); + BOOST_TEST(ec); BOOST_TEST_EQ(ec.message(), "unknown"); std::error_code sec = zstd::error::memory_allocation; @@ -400,9 +400,9 @@ struct zstd_test BOOST_TEST(dsvc.is_error( dsvc.find_frame_compressed_size(garbage.data(), garbage.size()))); - // the error code converts to a system::error_code - system::error_code ec = dsvc.get_error_code(rs); - BOOST_TEST(ec.failed()); + // the error code converts to a std::error_code + std::error_code ec = dsvc.get_error_code(rs); + BOOST_TEST(ec); BOOST_TEST_EQ(ec.message(), "prefix_unknown"); // successful results are not errors