diff --git a/CHANGELOG.md b/CHANGELOG.md index 36bc0863..64833cd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +Version 44 + +* Use BOOST_THROW_EXCEPTION + +-------------------------------------------------------------------------------- + Version 43 * Require Boost 1.64.0 diff --git a/extras/beast/test/fail_counter.hpp b/extras/beast/test/fail_counter.hpp index 7bfe486b..e263a31a 100644 --- a/extras/beast/test/fail_counter.hpp +++ b/extras/beast/test/fail_counter.hpp @@ -9,6 +9,7 @@ #define BEAST_TEST_FAIL_COUNTER_HPP #include +#include namespace beast { namespace test { @@ -114,7 +115,7 @@ public: if(n_ > 0) --n_; if(! n_) - throw system_error{ec_}; + BOOST_THROW_EXCEPTION(system_error{ec_}); } /// Set an error code on the Nth failure diff --git a/extras/beast/test/string_iostream.hpp b/extras/beast/test/string_iostream.hpp index 98342f73..11602746 100644 --- a/extras/beast/test/string_iostream.hpp +++ b/extras/beast/test/string_iostream.hpp @@ -15,6 +15,7 @@ #include #include #include +#include #include namespace beast { @@ -59,7 +60,7 @@ public: error_code ec; auto const n = read_some(buffers, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); return n; } @@ -104,7 +105,7 @@ public: error_code ec; auto const n = write_some(buffers, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); return n; } diff --git a/extras/beast/test/string_istream.hpp b/extras/beast/test/string_istream.hpp index 3c9352a1..059ad3eb 100644 --- a/extras/beast/test/string_istream.hpp +++ b/extras/beast/test/string_istream.hpp @@ -15,6 +15,7 @@ #include #include #include +#include #include namespace beast { @@ -57,7 +58,7 @@ public: error_code ec; auto const n = read_some(buffers, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); return n; } @@ -102,7 +103,7 @@ public: error_code ec; auto const n = write_some(buffers, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); return n; } diff --git a/extras/beast/test/string_ostream.hpp b/extras/beast/test/string_ostream.hpp index 591d35b6..397badfd 100644 --- a/extras/beast/test/string_ostream.hpp +++ b/extras/beast/test/string_ostream.hpp @@ -15,6 +15,7 @@ #include #include #include +#include #include namespace beast { @@ -50,7 +51,7 @@ public: error_code ec; auto const n = read_some(buffers, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); return n; } @@ -83,7 +84,7 @@ public: error_code ec; auto const n = write_some(buffers, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); return n; } diff --git a/extras/beast/unit_test/suite.hpp b/extras/beast/unit_test/suite.hpp index 1120daf4..ce0ec909 100644 --- a/extras/beast/unit_test/suite.hpp +++ b/extras/beast/unit_test/suite.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -551,7 +552,7 @@ fail(std::string const& reason) if(abort_) { aborted_ = true; - throw abort_exception(); + BOOST_THROW_EXCEPTION(abort_exception()); } } @@ -569,7 +570,7 @@ suite:: propagate_abort() { if(abort_ && aborted_) - throw abort_exception(); + BOOST_THROW_EXCEPTION(abort_exception()); } template diff --git a/include/beast/core/detail/sync_ostream.hpp b/include/beast/core/detail/sync_ostream.hpp index 40dbde38..45769ced 100644 --- a/include/beast/core/detail/sync_ostream.hpp +++ b/include/beast/core/detail/sync_ostream.hpp @@ -11,6 +11,8 @@ #include #include #include +#include +// BOOST_THROW_EXCEPTION( #include namespace beast { @@ -56,7 +58,7 @@ write_some(ConstBufferSequence const& buffers) error_code ec; auto const n = write_some(buffers, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); return n; } diff --git a/include/beast/core/detail/type_traits.hpp b/include/beast/core/detail/type_traits.hpp index d3467b7d..56473ed4 100644 --- a/include/beast/core/detail/type_traits.hpp +++ b/include/beast/core/detail/type_traits.hpp @@ -14,7 +14,6 @@ #include #include #include -#include #include namespace beast { @@ -88,18 +87,6 @@ struct repeat_tuple<0, T> using type = std::tuple<>; }; -template -Exception -make_exception(char const* reason, char const* file, int line) -{ - char const* n = file; - for(auto p = file; *p; ++p) - if(*p == '\\' || *p == '/') - n = p + 1; - return Exception{std::string(reason) + " (" + - n + ":" + std::to_string(line) + ")"}; -} - template auto is_invocable_test(C&& c, int, A&& ...a) diff --git a/include/beast/core/impl/buffer_cat.ipp b/include/beast/core/impl/buffer_cat.ipp index b3f86771..5b16c9c3 100644 --- a/include/beast/core/impl/buffer_cat.ipp +++ b/include/beast/core/impl/buffer_cat.ipp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -215,8 +216,8 @@ private: reference dereference(C const&) const { - throw detail::make_exception( - "invalid iterator", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::logic_error{ + "invalid iterator"}); } template @@ -232,8 +233,8 @@ private: void increment(C const&) { - throw detail::make_exception( - "invalid iterator", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::logic_error{ + "invalid iterator"}); } template @@ -274,8 +275,8 @@ private: --iter(); return; } - throw detail::make_exception( - "invalid iterator", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::logic_error{ + "invalid iterator"}); } template diff --git a/include/beast/core/impl/buffered_read_stream.ipp b/include/beast/core/impl/buffered_read_stream.ipp index 64cc4da7..a8c32b7f 100644 --- a/include/beast/core/impl/buffered_read_stream.ipp +++ b/include/beast/core/impl/buffered_read_stream.ipp @@ -15,6 +15,7 @@ #include #include #include +#include namespace beast { @@ -197,7 +198,7 @@ read_some( error_code ec; auto n = read_some(buffers, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); return n; } diff --git a/include/beast/core/impl/buffers_adapter.ipp b/include/beast/core/impl/buffers_adapter.ipp index 286cfa86..92e4800b 100644 --- a/include/beast/core/impl/buffers_adapter.ipp +++ b/include/beast/core/impl/buffers_adapter.ipp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -414,8 +415,8 @@ buffers_adapter::prepare(std::size_t n) -> } } if(n > 0) - throw detail::make_exception( - "no space", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::length_error{ + "no space"}); return mutable_buffers_type{*this}; } diff --git a/include/beast/core/impl/flat_buffer.ipp b/include/beast/core/impl/flat_buffer.ipp index 9787fb7c..c9a58867 100644 --- a/include/beast/core/impl/flat_buffer.ipp +++ b/include/beast/core/impl/flat_buffer.ipp @@ -9,6 +9,7 @@ #define BEAST_IMPL_FLAT_BUFFER_HPP #include +#include #include namespace beast { @@ -211,8 +212,8 @@ prepare(std::size_t n) -> } // enforce maximum capacity if(n > max_ - len) - throw std::length_error{ - "basic_flat_buffer overflow"}; + BOOST_THROW_EXCEPTION(std::length_error{ + "basic_flat_buffer overflow"}); // allocate a new buffer auto const new_size = (std::min)(max_, std::max( @@ -257,8 +258,8 @@ reserve(std::size_t n) if(n <= capacity()) return; if(n > max_) - throw std::length_error{ - "basic_flat_buffer overflow"}; + BOOST_THROW_EXCEPTION(std::length_error{ + "basic_flat_buffer overflow"}); auto const new_size = (std::min)(max_, std::max( detail::next_pow2(n), min_size)); diff --git a/include/beast/core/impl/multi_buffer.ipp b/include/beast/core/impl/multi_buffer.ipp index a2860090..481e25b7 100644 --- a/include/beast/core/impl/multi_buffer.ipp +++ b/include/beast/core/impl/multi_buffer.ipp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -523,8 +524,8 @@ basic_multi_buffer::basic_multi_buffer( , alloc_size_(alloc_size) { if(alloc_size <= 0) - throw detail::make_exception( - "invalid alloc_size", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::invalid_argument{ + "invalid alloc_size"}); } template diff --git a/include/beast/core/impl/static_buffer.ipp b/include/beast/core/impl/static_buffer.ipp index 8d681f33..92906d86 100644 --- a/include/beast/core/impl/static_buffer.ipp +++ b/include/beast/core/impl/static_buffer.ipp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -295,8 +296,8 @@ static_buffer::prepare(std::size_t n) -> mutable_buffers_type { if(n > static_cast(end_ - out_)) - throw detail::make_exception( - "static_buffer overflow", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::length_error{ + "static_buffer overflow"}); last_ = out_ + n; return mutable_buffers_type{out_, n}; } diff --git a/include/beast/core/impl/static_string.ipp b/include/beast/core/impl/static_string.ipp index 786eb516..7834d1cf 100644 --- a/include/beast/core/impl/static_string.ipp +++ b/include/beast/core/impl/static_string.ipp @@ -9,6 +9,7 @@ #define BEAST_IMPL_STATIC_STRING_IPP #include +#include namespace beast { @@ -119,8 +120,8 @@ assign(size_type count, CharT ch) -> static_string& { if(count > max_size()) - throw detail::make_exception( - "count > max_size()", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::length_error{ + "count > max_size()"}); n_ = count; Traits::assign(&s_[0], n_, ch); term(); @@ -157,8 +158,8 @@ assign(CharT const* s, size_type count) -> static_string& { if(count > max_size()) - throw detail::make_exception( - "count > max_size()", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::length_error{ + "count > max_size()"}); n_ = count; Traits::copy(&s_[0], s, n_); term(); @@ -174,8 +175,8 @@ assign(InputIt first, InputIt last) -> { std::size_t const n = std::distance(first, last); if(n > max_size()) - throw detail::make_exception( - "n > max_size()", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::length_error{ + "n > max_size()"}); n_ = n; for(auto it = &s_[0]; first != last; ++it, ++first) Traits::assign(*it, *first); @@ -193,8 +194,8 @@ assign(T const& t, size_type pos, size_type count) -> { auto const sv = string_view_type(t).substr(pos, count); if(sv.size() > max_size()) - throw detail::make_exception( - "sv.size() > max_size()", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::length_error{ + "sv.size() > max_size()"}); n_ = sv.size(); Traits::copy(&s_[0], &sv[0], n_); term(); @@ -212,8 +213,8 @@ at(size_type pos) -> reference { if(pos >= size()) - throw detail::make_exception( - "pos >= size()", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::out_of_range{ + "pos >= size()"}); return s_[pos]; } @@ -224,8 +225,8 @@ at(size_type pos) const -> const_reference { if(pos >= size()) - throw detail::make_exception( - "pos >= size()", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::out_of_range{ + "pos >= size()"}); return s_[pos]; } @@ -239,8 +240,8 @@ static_string:: reserve(std::size_t n) { if(n > max_size()) - throw detail::make_exception( - "n > max_size()", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::length_error{ + "n > max_size()"}); } // @@ -263,8 +264,8 @@ insert(size_type index, size_type count, CharT ch) -> static_string& { if(index > size()) - throw detail::make_exception( - "index > size()", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::out_of_range{ + "index > size()"}); insert(begin() + index, count, ch); return *this; } @@ -276,11 +277,11 @@ insert(size_type index, CharT const* s, size_type count) -> static_string& { if(index > size()) - throw detail::make_exception( - "index > size()", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::out_of_range{ + "index > size()"}); if(size() + count > max_size()) - throw detail::make_exception( - "size() + count > max_size()", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::length_error{ + "size() + count > max_size()"}); Traits::move( &s_[index + count], &s_[index], size() - index); n_ += count; @@ -309,8 +310,8 @@ insert(const_iterator pos, size_type count, CharT ch) -> iterator { if(size() + count > max_size()) - throw detail::make_exception( - "size() + count() > max_size()", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::length_error{ + "size() + count() > max_size()"}); auto const index = pos - &s_[0]; Traits::move( &s_[index + count], &s_[index], size() - index); @@ -331,8 +332,8 @@ insert(const_iterator pos, InputIt first, InputIt last) -> { std::size_t const count = std::distance(first, last); if(size() + count > max_size()) - throw detail::make_exception( - "size() + count > max_size()", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::length_error{ + "size() + count > max_size()"}); std::size_t const index = pos - begin(); Traits::move( &s_[index + count], &s_[index], size() - index); @@ -367,8 +368,8 @@ erase(size_type index, size_type count) -> static_string& { if(index > size()) - throw detail::make_exception( - "index > size()", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::out_of_range{ + "index > size()"}); auto const n = (std::min)(count, size() - index); Traits::move( &s_[index], &s_[index + n], size() - (index + n) + 1); @@ -403,8 +404,8 @@ static_string:: push_back(CharT ch) { if(size() >= max_size()) - throw detail::make_exception( - "size() >= max_size()", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::length_error{ + "size() >= max_size()"}); Traits::assign(s_[n_++], ch); term(); } @@ -419,8 +420,8 @@ append(static_string const& str, { // Valid range is [0, size) if(pos >= str.size()) - throw detail::make_exception( - "pos > str.size()", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::out_of_range{ + "pos > str.size()"}); string_view_type const ss{&str.s_[pos], (std::min)(count, str.size() - pos)}; insert(size(), ss.data(), ss.size()); @@ -434,8 +435,8 @@ substr(size_type pos, size_type count) const -> string_view_type { if(pos > size()) - throw detail::make_exception( - "pos > size()", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::out_of_range{ + "pos > size()"}); return{&s_[pos], (std::min)(count, size() - pos)}; } @@ -456,8 +457,8 @@ static_string:: resize(std::size_t n) { if(n > max_size()) - throw detail::make_exception( - "n > max_size()", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::length_error{ + "n > max_size()"}); n_ = n; term(); } @@ -468,8 +469,8 @@ static_string:: resize(std::size_t n, CharT c) { if(n > max_size()) - throw detail::make_exception( - "n > max_size()", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::length_error{ + "n > max_size()"}); if(n > n_) Traits::assign(&s_[n_], n - n_, c); n_ = n; @@ -495,11 +496,11 @@ static_string:: swap(static_string& str) { if(size() > str.max_size()) - throw detail::make_exception( - "size() > str.max_size()", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::length_error{ + "size() > str.max_size()"}); if(str.size() > max_size()) - throw detail::make_exception( - "str.size() > max_size()", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::length_error{ + "str.size() > max_size()"}); static_string tmp(str); str.n_ = n_; Traits::copy(&str.s_[0], &s_[0], n_ + 1); @@ -526,8 +527,8 @@ static_string:: assign_char(CharT ch, std::false_type) -> static_string& { - throw detail::make_exception( - "max_size() == 0", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::length_error{ + "max_size() == 0"}); } namespace detail { diff --git a/include/beast/http/header_parser.hpp b/include/beast/http/header_parser.hpp index c4350a00..747f9465 100644 --- a/include/beast/http/header_parser.hpp +++ b/include/beast/http/header_parser.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -162,8 +163,8 @@ private: { // Can't write body data with header-only parser! BOOST_ASSERT(false); - throw std::logic_error{ - "invalid member function call"}; + BOOST_THROW_EXCEPTION(std::logic_error{ + "invalid member function call"}); } void diff --git a/include/beast/http/impl/message.ipp b/include/beast/http/impl/message.ipp index f04f70b9..f2e6c1aa 100644 --- a/include/beast/http/impl/message.ipp +++ b/include/beast/http/impl/message.ipp @@ -16,6 +16,7 @@ #include #include #include +#include #include namespace beast { @@ -134,7 +135,7 @@ prepare_content_length(prepare_info& pi, error_code ec; w.init(ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); pi.content_length = w.content_length(); } @@ -157,8 +158,6 @@ void prepare(message& msg, Options&&... options) { - using beast::detail::make_exception; - // VFALCO TODO static_assert(is_Body::value, "Body requirements not met"); @@ -174,16 +173,16 @@ prepare(message& msg, std::forward(options)...); if(msg.fields.exists("Connection")) - throw make_exception( - "prepare called with Connection field set", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::invalid_argument{ + "prepare called with Connection field set"}); if(msg.fields.exists("Content-Length")) - throw make_exception( - "prepare called with Content-Length field set", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::invalid_argument{ + "prepare called with Content-Length field set"}); if(token_list{msg.fields["Transfer-Encoding"]}.exists("chunked")) - throw make_exception( - "prepare called with Transfer-Encoding: chunked set", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::invalid_argument{ + "prepare called with Transfer-Encoding: chunked set"}); if(pi.connection_value != connection::upgrade) { @@ -254,8 +253,8 @@ prepare(message& msg, // rfc7230 6.7. if(msg.version < 11 && token_list{ msg.fields["Connection"]}.exists("upgrade")) - throw make_exception( - "invalid version for Connection: upgrade", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::invalid_argument{ + "invalid version for Connection: upgrade"}); } namespace detail { diff --git a/include/beast/http/impl/read.ipp b/include/beast/http/impl/read.ipp index 651a7005..3c8e6152 100644 --- a/include/beast/http/impl/read.ipp +++ b/include/beast/http/impl/read.ipp @@ -20,6 +20,7 @@ #include #include #include +#include namespace beast { namespace http { @@ -203,7 +204,7 @@ read_some( auto const bytes_used = read_some(stream, buffer, parser, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); return bytes_used; } @@ -244,7 +245,7 @@ read( error_code ec; read(stream, buffer, parser, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); } template< @@ -298,7 +299,7 @@ read( error_code ec; beast::http::read(stream, buffer, msg, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); } template< diff --git a/include/beast/http/impl/write.ipp b/include/beast/http/impl/write.ipp index 129e4f9b..f78afd90 100644 --- a/include/beast/http/impl/write.ipp +++ b/include/beast/http/impl/write.ipp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -192,7 +193,7 @@ write(SyncWriteStream& stream, error_code ec; write(stream, msg, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); } template (std::numeric_limits::max)()) - throw std::length_error{ - "Content-Length overflow"}; + BOOST_THROW_EXCEPTION(std::length_error{ + "Content-Length overflow"}); body_.reserve(static_cast< std::size_t>(content_length)); } diff --git a/include/beast/websocket/impl/accept.ipp b/include/beast/websocket/impl/accept.ipp index c996121d..962d6ac0 100644 --- a/include/beast/websocket/impl/accept.ipp +++ b/include/beast/websocket/impl/accept.ipp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -316,7 +317,7 @@ accept() error_code ec; accept(ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); } template @@ -333,7 +334,7 @@ accept_ex(ResponseDecorator const& decorator) error_code ec; accept_ex(decorator, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); } template @@ -376,7 +377,7 @@ accept(ConstBufferSequence const& buffers) error_code ec; accept(buffers, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); } template @@ -398,7 +399,7 @@ accept_ex(ConstBufferSequence const& buffers, error_code ec; accept_ex(buffers, decorator, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); } template @@ -457,7 +458,7 @@ accept(http::header const& req) error_code ec; accept(req, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); } template @@ -475,7 +476,7 @@ accept_ex(http::header const& req, error_code ec; accept_ex(req, decorator, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); } template @@ -522,7 +523,7 @@ accept(http::header const& req, error_code ec; accept(req, buffers, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); } template @@ -545,7 +546,7 @@ accept_ex(http::header const& req, error_code ec; accept_ex(req, buffers, decorator, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); } template diff --git a/include/beast/websocket/impl/close.ipp b/include/beast/websocket/impl/close.ipp index 42c9fdeb..6b748f20 100644 --- a/include/beast/websocket/impl/close.ipp +++ b/include/beast/websocket/impl/close.ipp @@ -14,6 +14,7 @@ #include #include #include +#include #include namespace beast { @@ -227,7 +228,7 @@ close(close_reason const& cr) error_code ec; close(cr, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); } template diff --git a/include/beast/websocket/impl/handshake.ipp b/include/beast/websocket/impl/handshake.ipp index 944c7685..73f53bdb 100644 --- a/include/beast/websocket/impl/handshake.ipp +++ b/include/beast/websocket/impl/handshake.ipp @@ -18,6 +18,7 @@ #include #include #include +#include #include namespace beast { @@ -265,7 +266,7 @@ handshake(string_view const& host, handshake( host, target, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); } template @@ -280,7 +281,7 @@ handshake(response_type& res, error_code ec; handshake(res, host, target, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); } template @@ -299,7 +300,7 @@ handshake_ex(string_view const& host, error_code ec; handshake_ex(host, target, decorator, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); } template @@ -319,7 +320,7 @@ handshake_ex(response_type& res, error_code ec; handshake_ex(res, host, target, decorator, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); } template diff --git a/include/beast/websocket/impl/ping.ipp b/include/beast/websocket/impl/ping.ipp index e59b6cf7..905c9068 100644 --- a/include/beast/websocket/impl/ping.ipp +++ b/include/beast/websocket/impl/ping.ipp @@ -15,6 +15,7 @@ #include #include #include +#include #include namespace beast { @@ -240,7 +241,7 @@ ping(ping_data const& payload) error_code ec; ping(payload, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); } template @@ -262,7 +263,7 @@ pong(ping_data const& payload) error_code ec; pong(payload, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); } template diff --git a/include/beast/websocket/impl/read.ipp b/include/beast/websocket/impl/read.ipp index c1f97c6d..02af9f24 100644 --- a/include/beast/websocket/impl/read.ipp +++ b/include/beast/websocket/impl/read.ipp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -721,7 +722,7 @@ read_frame(frame_info& fi, DynamicBuffer& buffer) error_code ec; read_frame(fi, buffer, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); } template @@ -1136,7 +1137,7 @@ read(opcode& op, DynamicBuffer& buffer) error_code ec; read(op, buffer, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); } template diff --git a/include/beast/websocket/impl/stream.ipp b/include/beast/websocket/impl/stream.ipp index 1eb420e7..346cb90a 100644 --- a/include/beast/websocket/impl/stream.ipp +++ b/include/beast/websocket/impl/stream.ipp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -48,20 +49,20 @@ set_option(permessage_deflate const& o) { if( o.server_max_window_bits > 15 || o.server_max_window_bits < 9) - throw std::invalid_argument{ - "invalid server_max_window_bits"}; + BOOST_THROW_EXCEPTION(std::invalid_argument{ + "invalid server_max_window_bits"}); if( o.client_max_window_bits > 15 || o.client_max_window_bits < 9) - throw std::invalid_argument{ - "invalid client_max_window_bits"}; + BOOST_THROW_EXCEPTION(std::invalid_argument{ + "invalid client_max_window_bits"}); if( o.compLevel < 0 || o.compLevel > 9) - throw std::invalid_argument{ - "invalid compLevel"}; + BOOST_THROW_EXCEPTION(std::invalid_argument{ + "invalid compLevel"}); if( o.memLevel < 1 || o.memLevel > 9) - throw std::invalid_argument{ - "invalid memLevel"}; + BOOST_THROW_EXCEPTION(std::invalid_argument{ + "invalid memLevel"}); pmd_opts_ = o; } diff --git a/include/beast/websocket/impl/write.ipp b/include/beast/websocket/impl/write.ipp index df6e564e..0f94fc66 100644 --- a/include/beast/websocket/impl/write.ipp +++ b/include/beast/websocket/impl/write.ipp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -580,7 +581,7 @@ write_frame(bool fin, ConstBufferSequence const& buffers) error_code ec; write_frame(fin, buffers, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); } template @@ -932,7 +933,7 @@ write(ConstBufferSequence const& buffers) error_code ec; write(buffers, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); } template diff --git a/include/beast/websocket/option.hpp b/include/beast/websocket/option.hpp index 6b265e4d..ef6608e1 100644 --- a/include/beast/websocket/option.hpp +++ b/include/beast/websocket/option.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -90,8 +91,8 @@ struct message_type message_type(opcode op) { if(op != opcode::binary && op != opcode::text) - throw beast::detail::make_exception( - "bad opcode", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::invalid_argument{ + "bad opcode"}); value = op; } }; @@ -234,8 +235,8 @@ struct read_buffer_size : value(n) { if(n < 8) - throw beast::detail::make_exception( - "read buffer size is too small", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::invalid_argument{ + "read buffer size is too small"}); } }; #endif @@ -315,8 +316,8 @@ struct write_buffer_size : value(n) { if(n < 8) - throw beast::detail::make_exception( - "write buffer size is too small", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::invalid_argument{ + "write buffer size is too small"}); } }; #endif diff --git a/include/beast/zlib/detail/deflate_stream.hpp b/include/beast/zlib/detail/deflate_stream.hpp index 50358076..5ae0869d 100644 --- a/include/beast/zlib/detail/deflate_stream.hpp +++ b/include/beast/zlib/detail/deflate_stream.hpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -894,19 +895,17 @@ doReset( if(windowBits == 8) windowBits = 9; - using beast::detail::make_exception; - if(level < 0 || level > 9) - throw make_exception( - "invalid level", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::invalid_argument{ + "invalid level"}); if(windowBits < 8 || windowBits > 15) - throw make_exception( - "invalid windowBits", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::invalid_argument{ + "invalid windowBits"}); if(memLevel < 1 || memLevel > MAX_MEM_LEVEL) - throw make_exception( - "invalid memLevel", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::invalid_argument{ + "invalid memLevel"}); w_bits_ = windowBits; diff --git a/include/beast/zlib/detail/inflate_stream.hpp b/include/beast/zlib/detail/inflate_stream.hpp index fb2d4ce0..8f228508 100644 --- a/include/beast/zlib/detail/inflate_stream.hpp +++ b/include/beast/zlib/detail/inflate_stream.hpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -233,8 +234,8 @@ inflate_stream:: doReset(int windowBits) { if(windowBits < 8 || windowBits > 15) - throw beast::detail::make_exception( - "windowBits out of range", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::domain_error{ + "windowBits out of range"}); w_.reset(windowBits); bi_.flush(); @@ -708,8 +709,8 @@ doWrite(z_params& zs, Flush flush, error_code& ec) case SYNC: default: - throw beast::detail::make_exception( - "stream error", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::logic_error{ + "stream error"}); } } } @@ -935,8 +936,8 @@ inflate_table( auto const not_enough = [] { - throw beast::detail::make_exception( - "insufficient output size when inflating tables", __FILE__, __LINE__); + BOOST_THROW_EXCEPTION(std::logic_error{ + "insufficient output size when inflating tables"}); }; // check available table space @@ -1077,7 +1078,7 @@ get_fixed_tables() -> inflate_table(build::lens, lens, 288, &next, &lenbits, work, ec); if(ec) - throw std::logic_error{ec.message()}; + BOOST_THROW_EXCEPTION(std::logic_error{ec.message()}); } // VFALCO These fixups are from ZLib @@ -1093,7 +1094,7 @@ get_fixed_tables() -> inflate_table(build::dists, lens, 32, &next, &distbits, work, ec); if(ec) - throw std::logic_error{ec.message()}; + BOOST_THROW_EXCEPTION(std::logic_error{ec.message()}); } } }; diff --git a/test/http/nodejs_parser.hpp b/test/http/nodejs_parser.hpp index 8ee0764b..7f71eb42 100644 --- a/test/http/nodejs_parser.hpp +++ b/test/http/nodejs_parser.hpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -174,7 +175,7 @@ public: error_code ec; auto const used = write(data, size, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); return used; } @@ -189,7 +190,7 @@ public: error_code ec; auto const used = write(buffers, ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); return used; } @@ -204,7 +205,7 @@ public: error_code ec; write_eof(ec); if(ec) - throw system_error{ec}; + BOOST_THROW_EXCEPTION(system_error{ec}); } void