forked from boostorg/beast
@@ -1,3 +1,9 @@
|
||||
Version 44
|
||||
|
||||
* Use BOOST_THROW_EXCEPTION
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Version 43
|
||||
|
||||
* Require Boost 1.64.0
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#define BEAST_TEST_FAIL_COUNTER_HPP
|
||||
|
||||
#include <beast/core/error.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
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
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#include <beast/websocket/teardown.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <string>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#include <beast/websocket/teardown.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <string>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#include <beast/websocket/teardown.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <string>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include <beast/unit_test/runner.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
@@ -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<class>
|
||||
|
@@ -11,6 +11,8 @@
|
||||
#include <beast/core/error.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
// BOOST_THROW_EXCEPTION(
|
||||
#include <ostream>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@@ -14,7 +14,6 @@
|
||||
#include <iterator>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace beast {
|
||||
@@ -88,18 +87,6 @@ struct repeat_tuple<0, T>
|
||||
using type = std::tuple<>;
|
||||
};
|
||||
|
||||
template<class Exception>
|
||||
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<class R, class C, class ...A>
|
||||
auto
|
||||
is_invocable_test(C&& c, int, A&& ...a)
|
||||
|
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <iterator>
|
||||
@@ -215,8 +216,8 @@ private:
|
||||
reference
|
||||
dereference(C<sizeof...(Bn)> const&) const
|
||||
{
|
||||
throw detail::make_exception<std::logic_error>(
|
||||
"invalid iterator", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::logic_error{
|
||||
"invalid iterator"});
|
||||
}
|
||||
|
||||
template<std::size_t I>
|
||||
@@ -232,8 +233,8 @@ private:
|
||||
void
|
||||
increment(C<sizeof...(Bn)> const&)
|
||||
{
|
||||
throw detail::make_exception<std::logic_error>(
|
||||
"invalid iterator", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::logic_error{
|
||||
"invalid iterator"});
|
||||
}
|
||||
|
||||
template<std::size_t I>
|
||||
@@ -274,8 +275,8 @@ private:
|
||||
--iter<I>();
|
||||
return;
|
||||
}
|
||||
throw detail::make_exception<std::logic_error>(
|
||||
"invalid iterator", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::logic_error{
|
||||
"invalid iterator"});
|
||||
}
|
||||
|
||||
template<std::size_t I>
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <iterator>
|
||||
@@ -414,8 +415,8 @@ buffers_adapter<MutableBufferSequence>::prepare(std::size_t n) ->
|
||||
}
|
||||
}
|
||||
if(n > 0)
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"no space", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"no space"});
|
||||
return mutable_buffers_type{*this};
|
||||
}
|
||||
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#define BEAST_IMPL_FLAT_BUFFER_HPP
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
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<std::size_t>(
|
||||
@@ -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<std::size_t>(
|
||||
detail::next_pow2(n), min_size));
|
||||
|
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <algorithm>
|
||||
#include <exception>
|
||||
#include <sstream>
|
||||
@@ -523,8 +524,8 @@ basic_multi_buffer<Allocator>::basic_multi_buffer(
|
||||
, alloc_size_(alloc_size)
|
||||
{
|
||||
if(alloc_size <= 0)
|
||||
throw detail::make_exception<std::invalid_argument>(
|
||||
"invalid alloc_size", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument{
|
||||
"invalid alloc_size"});
|
||||
}
|
||||
|
||||
template<class Allocator>
|
||||
|
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <iterator>
|
||||
@@ -295,8 +296,8 @@ static_buffer::prepare(std::size_t n) ->
|
||||
mutable_buffers_type
|
||||
{
|
||||
if(n > static_cast<std::size_t>(end_ - out_))
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"static_buffer overflow", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"static_buffer overflow"});
|
||||
last_ = out_ + n;
|
||||
return mutable_buffers_type{out_, n};
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#define BEAST_IMPL_STATIC_STRING_IPP
|
||||
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
namespace beast {
|
||||
|
||||
@@ -119,8 +120,8 @@ assign(size_type count, CharT ch) ->
|
||||
static_string&
|
||||
{
|
||||
if(count > max_size())
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"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<std::length_error>(
|
||||
"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<std::length_error>(
|
||||
"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<std::length_error>(
|
||||
"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<std::out_of_range>(
|
||||
"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<std::out_of_range>(
|
||||
"pos >= size()", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::out_of_range{
|
||||
"pos >= size()"});
|
||||
return s_[pos];
|
||||
}
|
||||
|
||||
@@ -239,8 +240,8 @@ static_string<N, CharT, Traits>::
|
||||
reserve(std::size_t n)
|
||||
{
|
||||
if(n > max_size())
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"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<std::out_of_range>(
|
||||
"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<std::out_of_range>(
|
||||
"index > size()", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::out_of_range{
|
||||
"index > size()"});
|
||||
if(size() + count > max_size())
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"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<std::length_error>(
|
||||
"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<std::length_error>(
|
||||
"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<std::out_of_range>(
|
||||
"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<N, CharT, Traits>::
|
||||
push_back(CharT ch)
|
||||
{
|
||||
if(size() >= max_size())
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"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<M, CharT, Traits> const& str,
|
||||
{
|
||||
// Valid range is [0, size)
|
||||
if(pos >= str.size())
|
||||
throw detail::make_exception<std::out_of_range>(
|
||||
"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<std::out_of_range>(
|
||||
"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<N, CharT, Traits>::
|
||||
resize(std::size_t n)
|
||||
{
|
||||
if(n > max_size())
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"n > max_size()", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"n > max_size()"});
|
||||
n_ = n;
|
||||
term();
|
||||
}
|
||||
@@ -468,8 +469,8 @@ static_string<N, CharT, Traits>::
|
||||
resize(std::size_t n, CharT c)
|
||||
{
|
||||
if(n > max_size())
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"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<N, CharT, Traits>::
|
||||
swap(static_string<M, CharT, Traits>& str)
|
||||
{
|
||||
if(size() > str.max_size())
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"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<std::length_error>(
|
||||
"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<N, CharT, Traits>::
|
||||
assign_char(CharT ch, std::false_type) ->
|
||||
static_string&
|
||||
{
|
||||
throw detail::make_exception<std::length_error>(
|
||||
"max_size() == 0", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"max_size() == 0"});
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include <beast/config.hpp>
|
||||
#include <beast/http/message.hpp>
|
||||
#include <beast/http/basic_parser.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <array>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
@@ -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
|
||||
|
@@ -16,6 +16,7 @@
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
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<isRequest, Body, Fields>& msg,
|
||||
Options&&... options)
|
||||
{
|
||||
using beast::detail::make_exception;
|
||||
|
||||
// VFALCO TODO
|
||||
static_assert(is_Body<Body>::value,
|
||||
"Body requirements not met");
|
||||
@@ -174,16 +173,16 @@ prepare(message<isRequest, Body, Fields>& msg,
|
||||
std::forward<Options>(options)...);
|
||||
|
||||
if(msg.fields.exists("Connection"))
|
||||
throw make_exception<std::invalid_argument>(
|
||||
"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<std::invalid_argument>(
|
||||
"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<std::invalid_argument>(
|
||||
"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<isRequest, Body, Fields>& msg,
|
||||
// rfc7230 6.7.
|
||||
if(msg.version < 11 && token_list{
|
||||
msg.fields["Connection"]}.exists("upgrade"))
|
||||
throw make_exception<std::invalid_argument>(
|
||||
"invalid version for Connection: upgrade", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument{
|
||||
"invalid version for Connection: upgrade"});
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
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<
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/asio/write.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <ostream>
|
||||
@@ -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<class SyncWriteStream,
|
||||
@@ -584,7 +585,7 @@ write(SyncWriteStream& stream,
|
||||
error_code ec;
|
||||
write(stream, msg, ec);
|
||||
if(ec)
|
||||
throw system_error{ec};
|
||||
BOOST_THROW_EXCEPTION(system_error{ec});
|
||||
}
|
||||
|
||||
template<class SyncWriteStream,
|
||||
@@ -682,7 +683,7 @@ operator<<(std::ostream& os,
|
||||
error_code ec;
|
||||
write(oss, msg, ec);
|
||||
if(ec)
|
||||
throw system_error{ec};
|
||||
BOOST_THROW_EXCEPTION(system_error{ec});
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -702,7 +703,7 @@ operator<<(std::ostream& os,
|
||||
error_code ec;
|
||||
write(oss, msg, ec);
|
||||
if(ec && ec != boost::asio::error::eof)
|
||||
throw system_error{ec};
|
||||
BOOST_THROW_EXCEPTION(system_error{ec});
|
||||
return os;
|
||||
}
|
||||
|
||||
|
@@ -61,8 +61,8 @@ private:
|
||||
{
|
||||
if(content_length >
|
||||
(std::numeric_limits<std::size_t>::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));
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
@@ -316,7 +317,7 @@ accept()
|
||||
error_code ec;
|
||||
accept(ec);
|
||||
if(ec)
|
||||
throw system_error{ec};
|
||||
BOOST_THROW_EXCEPTION(system_error{ec});
|
||||
}
|
||||
|
||||
template<class NextLayer>
|
||||
@@ -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<class NextLayer>
|
||||
@@ -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<class NextLayer>
|
||||
@@ -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<class NextLayer>
|
||||
@@ -457,7 +458,7 @@ accept(http::header<true, Fields> const& req)
|
||||
error_code ec;
|
||||
accept(req, ec);
|
||||
if(ec)
|
||||
throw system_error{ec};
|
||||
BOOST_THROW_EXCEPTION(system_error{ec});
|
||||
}
|
||||
|
||||
template<class NextLayer>
|
||||
@@ -475,7 +476,7 @@ accept_ex(http::header<true, Fields> const& req,
|
||||
error_code ec;
|
||||
accept_ex(req, decorator, ec);
|
||||
if(ec)
|
||||
throw system_error{ec};
|
||||
BOOST_THROW_EXCEPTION(system_error{ec});
|
||||
}
|
||||
|
||||
template<class NextLayer>
|
||||
@@ -522,7 +523,7 @@ accept(http::header<true, Fields> const& req,
|
||||
error_code ec;
|
||||
accept(req, buffers, ec);
|
||||
if(ec)
|
||||
throw system_error{ec};
|
||||
BOOST_THROW_EXCEPTION(system_error{ec});
|
||||
}
|
||||
|
||||
template<class NextLayer>
|
||||
@@ -545,7 +546,7 @@ accept_ex(http::header<true, Fields> const& req,
|
||||
error_code ec;
|
||||
accept_ex(req, buffers, decorator, ec);
|
||||
if(ec)
|
||||
throw system_error{ec};
|
||||
BOOST_THROW_EXCEPTION(system_error{ec});
|
||||
}
|
||||
|
||||
template<class NextLayer>
|
||||
|
@@ -14,6 +14,7 @@
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <memory>
|
||||
|
||||
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<class NextLayer>
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <memory>
|
||||
|
||||
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<class NextLayer>
|
||||
@@ -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<class NextLayer>
|
||||
@@ -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<class NextLayer>
|
||||
@@ -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<class NextLayer>
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <memory>
|
||||
|
||||
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<class NextLayer>
|
||||
@@ -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<class NextLayer>
|
||||
|
@@ -19,6 +19,7 @@
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
|
||||
@@ -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<class NextLayer>
|
||||
@@ -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<class NextLayer>
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/endian/buffers.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
@@ -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<class NextLayer>
|
||||
@@ -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<class NextLayer>
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include <beast/config.hpp>
|
||||
#include <beast/websocket/rfc6455.hpp>
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
@@ -90,8 +91,8 @@ struct message_type
|
||||
message_type(opcode op)
|
||||
{
|
||||
if(op != opcode::binary && op != opcode::text)
|
||||
throw beast::detail::make_exception<std::invalid_argument>(
|
||||
"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<std::invalid_argument>(
|
||||
"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<std::invalid_argument>(
|
||||
"write buffer size is too small", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument{
|
||||
"write buffer size is too small"});
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
@@ -40,6 +40,7 @@
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
@@ -894,19 +895,17 @@ doReset(
|
||||
if(windowBits == 8)
|
||||
windowBits = 9;
|
||||
|
||||
using beast::detail::make_exception;
|
||||
|
||||
if(level < 0 || level > 9)
|
||||
throw make_exception<std::invalid_argument>(
|
||||
"invalid level", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument{
|
||||
"invalid level"});
|
||||
|
||||
if(windowBits < 8 || windowBits > 15)
|
||||
throw make_exception<std::invalid_argument>(
|
||||
"invalid windowBits", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument{
|
||||
"invalid windowBits"});
|
||||
|
||||
if(memLevel < 1 || memLevel > MAX_MEM_LEVEL)
|
||||
throw make_exception<std::invalid_argument>(
|
||||
"invalid memLevel", __FILE__, __LINE__);
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument{
|
||||
"invalid memLevel"});
|
||||
|
||||
w_bits_ = windowBits;
|
||||
|
||||
|
@@ -41,6 +41,7 @@
|
||||
#include <beast/zlib/detail/ranges.hpp>
|
||||
#include <beast/zlib/detail/window.hpp>
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
@@ -233,8 +234,8 @@ inflate_stream::
|
||||
doReset(int windowBits)
|
||||
{
|
||||
if(windowBits < 8 || windowBits > 15)
|
||||
throw beast::detail::make_exception<std::domain_error>(
|
||||
"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<std::logic_error>(
|
||||
"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<std::logic_error>(
|
||||
"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()});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@@ -16,6 +16,7 @@
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
@@ -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
|
||||
|
Reference in New Issue
Block a user