Tidy up error types:

* Restructure header material
* Clean up namespace type injections
* Remove extraneous 'success' constants
This commit is contained in:
Vinnie Falco
2016-10-04 18:00:11 -04:00
parent f2a283ed10
commit 6b0b016b21
23 changed files with 260 additions and 292 deletions

View File

@ -5,6 +5,7 @@
* Add Secure WebSocket example * Add Secure WebSocket example
* Fix message_v1 constructor * Fix message_v1 constructor
* Tidy up DynamicBuffer requirements * Tidy up DynamicBuffer requirements
* Tidy up error types and headers
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@ -139,7 +139,10 @@
<member><link linkend="beast.ref.buffers_adapter">buffers_adapter</link></member> <member><link linkend="beast.ref.buffers_adapter">buffers_adapter</link></member>
<member><link linkend="beast.ref.consuming_buffers">consuming_buffers</link></member> <member><link linkend="beast.ref.consuming_buffers">consuming_buffers</link></member>
<member><link linkend="beast.ref.dynabuf_readstream">dynabuf_readstream</link></member> <member><link linkend="beast.ref.dynabuf_readstream">dynabuf_readstream</link></member>
<member><link linkend="beast.ref.errc">errc</link></member>
<member><link linkend="beast.ref.error_category">error_category</link></member>
<member><link linkend="beast.ref.error_code">error_code</link></member> <member><link linkend="beast.ref.error_code">error_code</link></member>
<member><link linkend="beast.ref.error_condition">error_condition</link></member>
<member><link linkend="beast.ref.handler_alloc">handler_alloc</link></member> <member><link linkend="beast.ref.handler_alloc">handler_alloc</link></member>
<member><link linkend="beast.ref.prepared_buffers">prepared_buffers</link></member> <member><link linkend="beast.ref.prepared_buffers">prepared_buffers</link></member>
<member><link linkend="beast.ref.static_streambuf">static_streambuf</link></member> <member><link linkend="beast.ref.static_streambuf">static_streambuf</link></member>

View File

@ -49,7 +49,7 @@ int main(int, char const*[])
beast::http::read(sock, sb, res); beast::http::read(sock, sb, res);
std::cout << res; std::cout << res;
} }
catch(boost::system::system_error const& ec) catch(beast::system_error const& ec)
{ {
std::cerr << host << ": " << ec.what(); std::cerr << host << ": " << ec.what();
} }

View File

@ -13,11 +13,9 @@
namespace beast { namespace beast {
namespace test { namespace test {
enum error enum class error
{ {
success = 0, fail_error = 1
fail_error
}; };
namespace detail { namespace detail {
@ -79,14 +77,15 @@ inline
error_code error_code
make_error_code(error ev) make_error_code(error ev)
{ {
return error_code{static_cast<int>(ev), return error_code{
detail::get_error_category()}; static_cast<std::underlying_type<error>::type>(ev),
detail::get_error_category()};
} }
/** A countdown to simulated failure. /** A countdown to simulated failure.
On the Nth operation, the class will fail with the specified On the Nth operation, the class will fail with the specified
error code, or the default error code of @ref fail_error. error code, or the default error code of @ref error::fail_error.
*/ */
class fail_counter class fail_counter
{ {
@ -102,7 +101,7 @@ public:
*/ */
explicit explicit
fail_counter(std::size_t n, fail_counter(std::size_t n,
error_code ev = make_error_code(fail_error)) error_code ev = make_error_code(error::fail_error))
: n_(n) : n_(n)
, ec_(ev) , ec_(ev)
{ {

View File

@ -34,11 +34,11 @@ namespace beast {
... ...
template<class CompletionHandler> template<class CompletionHandler>
typename async_completion<CompletionHandler, typename async_completion<CompletionHandler,
void(boost::system::error_code)>::result_type void(error_code)>::result_type
async_initfn(..., CompletionHandler&& handler) async_initfn(..., CompletionHandler&& handler)
{ {
async_completion<CompletionHandler, async_completion<CompletionHandler,
void(boost::system::error_code)> completion(handler); void(error_code)> completion(handler);
... ...
return completion.result.get(); return completion.result.get();
} }

View File

@ -9,6 +9,7 @@
#define BEAST_DETAIL_STREAM_CONCEPTS_HPP #define BEAST_DETAIL_STREAM_CONCEPTS_HPP
#include <beast/core/buffer_concepts.hpp> #include <beast/core/buffer_concepts.hpp>
#include <beast/core/error.hpp>
#include <boost/asio/io_service.hpp> #include <boost/asio/io_service.hpp>
#include <boost/system/error_code.hpp> #include <boost/system/error_code.hpp>
#include <type_traits> #include <type_traits>
@ -22,7 +23,7 @@ namespace detail {
struct StreamHandler struct StreamHandler
{ {
StreamHandler(StreamHandler const&) = default; StreamHandler(StreamHandler const&) = default;
void operator()(boost::system::error_code ec, std::size_t); void operator()(error_code ec, std::size_t);
}; };
using ReadHandler = StreamHandler; using ReadHandler = StreamHandler;
using WriteHandler = StreamHandler; using WriteHandler = StreamHandler;
@ -79,9 +80,6 @@ public:
template<class T> template<class T>
class is_SyncReadStream class is_SyncReadStream
{ {
using error_code =
boost::system::error_code;
template<class U, class R = std::is_same<decltype( template<class U, class R = std::is_same<decltype(
std::declval<U>().read_some( std::declval<U>().read_some(
std::declval<MutableBufferSequence>())), std::declval<MutableBufferSequence>())),
@ -108,9 +106,6 @@ public:
template<class T> template<class T>
class is_SyncWriteStream class is_SyncWriteStream
{ {
using error_code =
boost::system::error_code;
template<class U, class R = std::is_same<decltype( template<class U, class R = std::is_same<decltype(
std::declval<U>().write_some( std::declval<U>().write_some(
std::declval<ConstBufferSequence>())), std::declval<ConstBufferSequence>())),

View File

@ -19,6 +19,18 @@ using error_code = boost::system::error_code;
/// The type of system error thrown by the library /// The type of system error thrown by the library
using system_error = boost::system::system_error; using system_error = boost::system::system_error;
/// The type of error category used by the library
using error_category = boost::system::error_category;
/// The type of error condition used by the library
using error_condition = boost::system::error_condition;
/// The set of constants used for cross-platform error codes
#if GENERATING_DOCS
enum errc{};
#else
namespace errc = boost::system::errc;
#endif
} // beast } // beast
#endif #endif

View File

@ -0,0 +1,107 @@
//
// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BEAST_HTTP_IMPL_PARSE_ERROR_IPP
#define BEAST_HTTP_IMPL_PARSE_ERROR_IPP
namespace boost {
namespace system {
template<>
struct is_error_code_enum<beast::http::parse_error>
{
static bool const value = true;
};
} // system
} // boost
namespace beast {
namespace http {
namespace detail {
class parse_error_category : public error_category
{
public:
const char*
name() const noexcept override
{
return "http";
}
std::string
message(int ev) const override
{
switch(static_cast<parse_error>(ev))
{
case parse_error::connection_closed: return "data after Connection close";
case parse_error::bad_method: return "bad method";
case parse_error::bad_uri: return "bad request-target";
case parse_error::bad_version: return "bad HTTP-Version";
case parse_error::bad_crlf: return "missing CRLF";
case parse_error::bad_status: return "bad status-code";
case parse_error::bad_reason: return "bad reason-phrase";
case parse_error::bad_field: return "bad field token";
case parse_error::bad_value: return "bad field-value";
case parse_error::bad_content_length: return "bad Content-Length";
case parse_error::illegal_content_length: return "illegal Content-Length with chunked Transfer-Encoding";
case parse_error::bad_on_headers_rv: return "on_headers returned an unknown value";
case parse_error::invalid_chunk_size: return "invalid chunk size";
case parse_error::invalid_ext_name: return "invalid ext name";
case parse_error::invalid_ext_val: return "invalid ext val";
case parse_error::headers_too_big: return "headers size limit exceeded";
case parse_error::body_too_big: return "body size limit exceeded";
case parse_error::short_read: return "unexpected end of data";
default:
return "parse error";
}
}
error_condition
default_error_condition(int ev) const noexcept override
{
return error_condition{ev, *this};
}
bool
equivalent(int ev,
error_condition const& condition
) const noexcept override
{
return condition.value() == ev &&
&condition.category() == this;
}
bool
equivalent(error_code const& error, int ev) const noexcept override
{
return error.value() == ev &&
&error.category() == this;
}
};
inline
error_category const&
get_parse_error_category()
{
static parse_error_category const cat{};
return cat;
}
} // detail
inline
error_code
make_error_code(parse_error ev)
{
return error_code{
static_cast<std::underlying_type<parse_error>::type>(ev),
detail::get_parse_error_category()};
}
} // http
} // beast
#endif

View File

@ -332,7 +332,7 @@ parse(SyncReadStream& stream,
error_code ec; error_code ec;
parse(stream, dynabuf, parser, ec); parse(stream, dynabuf, parser, ec);
if(ec) if(ec)
throw boost::system::system_error{ec}; throw system_error{ec};
} }
template<class SyncReadStream, class DynamicBuffer, class Parser> template<class SyncReadStream, class DynamicBuffer, class Parser>

View File

@ -462,7 +462,7 @@ template<class SyncWriteStream,
void void
write(SyncWriteStream& stream, write(SyncWriteStream& stream,
message_v1<isRequest, Body, Headers> const& msg, message_v1<isRequest, Body, Headers> const& msg,
boost::system::error_code& ec) error_code& ec)
{ {
static_assert(is_SyncWriteStream<SyncWriteStream>::value, static_assert(is_SyncWriteStream<SyncWriteStream>::value,
"SyncWriteStream requirements not met"); "SyncWriteStream requirements not met");
@ -596,8 +596,8 @@ public:
buffer_size(buffer)); buffer_size(buffer));
if(os_.fail()) if(os_.fail())
{ {
ec = boost::system::errc::make_error_code( ec = errc::make_error_code(
boost::system::errc::no_stream_resources); errc::no_stream_resources);
break; break;
} }
n += buffer_size(buffer); n += buffer_size(buffer);

View File

@ -15,15 +15,12 @@ namespace http {
enum class parse_error enum class parse_error
{ {
success = 0, connection_closed = 1,
connection_closed,
bad_method, bad_method,
bad_uri, bad_uri,
bad_version, bad_version,
bad_crlf, bad_crlf,
bad_request,
bad_status, bad_status,
bad_reason, bad_reason,
@ -45,132 +42,9 @@ enum class parse_error
general general
}; };
class parse_error_category : public boost::system::error_category
{
public:
const char*
name() const noexcept override
{
return "http";
}
std::string
message(int ev) const override
{
switch(static_cast<parse_error>(ev))
{
case parse_error::connection_closed:
return "data after Connection close";
case parse_error::bad_method:
return "bad method";
case parse_error::bad_uri:
return "bad request-target";
case parse_error::bad_version:
return "bad HTTP-Version";
case parse_error::bad_crlf:
return "missing CRLF";
case parse_error::bad_request:
return "bad reason-phrase";
case parse_error::bad_status:
return "bad status-code";
case parse_error::bad_reason:
return "bad reason-phrase";
case parse_error::bad_field:
return "bad field token";
case parse_error::bad_value:
return "bad field-value";
case parse_error::bad_content_length:
return "bad Content-Length";
case parse_error::illegal_content_length:
return "illegal Content-Length with chunked Transfer-Encoding";
case parse_error::bad_on_headers_rv:
return "on_headers returned an unknown value";
case parse_error::invalid_chunk_size:
return "invalid chunk size";
case parse_error::invalid_ext_name:
return "invalid ext name";
case parse_error::invalid_ext_val:
return "invalid ext val";
case parse_error::headers_too_big:
return "headers size limit exceeded";
case parse_error::body_too_big:
return "body size limit exceeded";
case parse_error::short_read:
return "unexpected end of data";
default:
return "parse error";
}
}
boost::system::error_condition
default_error_condition(int ev) const noexcept override
{
return boost::system::error_condition(ev, *this);
}
bool
equivalent(int ev,
boost::system::error_condition const& condition
) const noexcept override
{
return condition.value() == ev &&
&condition.category() == this;
}
bool
equivalent(error_code const& error, int ev) const noexcept override
{
return error.value() == ev &&
&error.category() == this;
}
};
inline
boost::system::error_category const&
get_parse_error_category()
{
static parse_error_category const cat{};
return cat;
}
inline
boost::system::error_code
make_error_code(parse_error ev)
{
return error_code(static_cast<int>(ev),
get_parse_error_category());
}
} // http } // http
} // beast } // beast
namespace boost { #include <beast/http/impl/parse_error.ipp>
namespace system {
template<>
struct is_error_code_enum<beast::http::parse_error>
{
static bool const value = true;
};
} // system
} // boost
#endif #endif

View File

@ -44,7 +44,7 @@ namespace http {
@param parser An object meeting the requirements of Parser @param parser An object meeting the requirements of Parser
which will receive the data. which will receive the data.
@throws boost::system::system_error on failure. @throws system_error Thrown on failure.
*/ */
template<class SyncReadStream, class DynamicBuffer, class Parser> template<class SyncReadStream, class DynamicBuffer, class Parser>
void void
@ -165,7 +165,7 @@ async_parse(AsyncReadStream& stream, DynamicBuffer& dynabuf,
@param msg An object used to store the message. Any @param msg An object used to store the message. Any
contents will be overwritten. contents will be overwritten.
@throws boost::system::system_error Thrown on failure. @throws system_error Thrown on failure.
*/ */
template<class SyncReadStream, class DynamicBuffer, template<class SyncReadStream, class DynamicBuffer,
bool isRequest, class Body, class Headers> bool isRequest, class Body, class Headers>

View File

@ -40,7 +40,7 @@ namespace http {
@param msg The message to write. @param msg The message to write.
@throws boost::system::error Thrown on failure. @throws system_error Thrown on failure.
*/ */
template<class SyncWriteStream, template<class SyncWriteStream,
bool isRequest, class Body, class Headers> bool isRequest, class Body, class Headers>

View File

@ -1,92 +0,0 @@
//
// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BEAST_WEBSOCKET_DETAIL_ERROR_HPP
#define BEAST_WEBSOCKET_DETAIL_ERROR_HPP
#include <beast/websocket/error.hpp>
namespace boost {
namespace system {
template<>
struct is_error_code_enum<beast::websocket::error>
{
static bool const value = true;
};
} // system
} // boost
namespace beast {
namespace websocket {
namespace detail {
class error_category : public boost::system::error_category
{
public:
const char*
name() const noexcept override
{
return "websocket";
}
std::string
message(int ev) const override
{
switch(static_cast<error>(ev))
{
case error::closed: return "WebSocket connection closed normally";
case error::failed: return "WebSocket connection failed due to a protocol violation";
case error::handshake_failed: return "WebSocket Upgrade handshake failed";
case error::keep_alive: return "WebSocket Upgrade handshake failed but connection is still open";
case error::response_malformed: return "malformed HTTP response";
case error::response_failed: return "upgrade request failed";
case error::response_denied: return "upgrade request denied";
case error::request_malformed: return "malformed HTTP request";
case error::request_invalid: return "upgrade request invalid";
case error::request_denied: return "upgrade request denied";
default:
return "websocket error";
}
}
boost::system::error_condition
default_error_condition(int ev) const noexcept override
{
return boost::system::error_condition(ev, *this);
}
bool
equivalent(int ev,
boost::system::error_condition const& condition
) const noexcept override
{
return condition.value() == ev &&
&condition.category() == this;
}
bool
equivalent(error_code const& error, int ev) const noexcept override
{
return error.value() == ev &&
&error.category() == this;
}
};
inline
boost::system::error_category const&
get_error_category()
{
static detail::error_category const cat{};
return cat;
}
} // detail
} // websocket
} // beast
#endif

View File

@ -16,10 +16,8 @@ namespace websocket {
/// Error codes returned from @ref stream operations. /// Error codes returned from @ref stream operations.
enum class error enum class error
{ {
success = 0,
/// Both sides performed a WebSocket close /// Both sides performed a WebSocket close
closed, closed = 1,
/// WebSocket connection failed, protocol violation /// WebSocket connection failed, protocol violation
failed, failed,
@ -52,11 +50,6 @@ enum class error
general general
}; };
#if ! GENERATING_DOCS
error_code
make_error_code(error e);
#endif
} // websocket } // websocket
} // beast } // beast

View File

@ -5,20 +5,93 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// //
#ifndef BEAST_WEBSOCKET_IMPL_ERROR_IPP_HPP #ifndef BEAST_WEBSOCKET_IMPL_ERROR_IPP
#define BEAST_WEBSOCKET_IMPL_ERROR_IPP_HPP #define BEAST_WEBSOCKET_IMPL_ERROR_IPP
#include <beast/websocket/detail/error.hpp> namespace boost {
namespace system {
template<>
struct is_error_code_enum<beast::websocket::error>
{
static bool const value = true;
};
} // system
} // boost
namespace beast { namespace beast {
namespace websocket { namespace websocket {
namespace detail {
class websocket_error_category : public error_category
{
public:
const char*
name() const noexcept override
{
return "websocket";
}
std::string
message(int ev) const override
{
switch(static_cast<error>(ev))
{
case error::closed: return "WebSocket connection closed normally";
case error::failed: return "WebSocket connection failed due to a protocol violation";
case error::handshake_failed: return "WebSocket Upgrade handshake failed";
case error::keep_alive: return "WebSocket Upgrade handshake failed but connection is still open";
case error::response_malformed: return "malformed HTTP response";
case error::response_failed: return "upgrade request failed";
case error::response_denied: return "upgrade request denied";
case error::request_malformed: return "malformed HTTP request";
case error::request_invalid: return "upgrade request invalid";
case error::request_denied: return "upgrade request denied";
default:
return "websocket error";
}
}
error_condition
default_error_condition(int ev) const noexcept override
{
return error_condition(ev, *this);
}
bool
equivalent(int ev,
error_condition const& condition
) const noexcept override
{
return condition.value() == ev &&
&condition.category() == this;
}
bool
equivalent(error_code const& error, int ev) const noexcept override
{
return error.value() == ev &&
&error.category() == this;
}
};
inline
error_category const&
get_error_category()
{
static detail::websocket_error_category const cat{};
return cat;
}
} // detail
inline inline
error_code error_code
make_error_code(error e) make_error_code(error e)
{ {
return error_code( return error_code(
static_cast<int>(e), detail::get_error_category()); static_cast<std::underlying_type<error>::type>(e),
detail::get_error_category());
} }
} // websocket } // websocket

View File

@ -352,7 +352,7 @@ public:
HTTP response is sent indicating the reason and status code HTTP response is sent indicating the reason and status code
(typically 400, "Bad Request"). This counts as a failure. (typically 400, "Bad Request"). This counts as a failure.
@throws boost::system::system_error Thrown on failure. @throws system_error Thrown on failure.
*/ */
void void
accept(); accept();
@ -462,7 +462,7 @@ public:
then to received WebSocket frames. The implementation will then to received WebSocket frames. The implementation will
copy the caller provided data before the function returns. copy the caller provided data before the function returns.
@throws boost::system::system_error Thrown on failure. @throws system_error Thrown on failure.
*/ */
template<class ConstBufferSequence> template<class ConstBufferSequence>
void void
@ -585,7 +585,7 @@ public:
Ownership is not transferred, the implementation will not access Ownership is not transferred, the implementation will not access
this object from other threads. this object from other threads.
@throws boost::system::system_error Thrown on failure. @throws system_error Thrown on failure.
*/ */
// VFALCO TODO This should also take a DynamicBuffer with any leftover bytes. // VFALCO TODO This should also take a DynamicBuffer with any leftover bytes.
template<class Body, class Headers> template<class Body, class Headers>
@ -700,7 +700,7 @@ public:
@param resource The requesting URI, which may not be empty, @param resource The requesting URI, which may not be empty,
required by the HTTP protocol. required by the HTTP protocol.
@throws boost::system::system_error Thrown on failure. @throws system_error Thrown on failure.
@par Example @par Example
@code @code
@ -837,7 +837,7 @@ public:
@param cr The reason for the close. @param cr The reason for the close.
@throws boost::system::system_error Thrown on failure. @throws system_error Thrown on failure.
*/ */
void void
close(close_reason const& cr); close(close_reason const& cr);
@ -937,7 +937,7 @@ public:
@param payload The payload of the ping message, which may be empty. @param payload The payload of the ping message, which may be empty.
@throws boost::system::system_error Thrown on failure. @throws system_error Thrown on failure.
*/ */
void void
ping(ping_data const& payload); ping(ping_data const& payload);
@ -1031,7 +1031,7 @@ public:
@param dynabuf A dynamic buffer to hold the message data after @param dynabuf A dynamic buffer to hold the message data after
any masking or decompression has been applied. any masking or decompression has been applied.
@throws boost::system::system_error Thrown on failure. @throws system_error Thrown on failure.
*/ */
template<class DynamicBuffer> template<class DynamicBuffer>
void void
@ -1166,7 +1166,7 @@ public:
@param dynabuf A dynamic buffer to hold the message data after @param dynabuf A dynamic buffer to hold the message data after
any masking or decompression has been applied. any masking or decompression has been applied.
@throws boost::system::system_error Thrown on failure. @throws system_error Thrown on failure.
*/ */
template<class DynamicBuffer> template<class DynamicBuffer>
void void
@ -1304,7 +1304,7 @@ public:
the memory locations pointed to by buffers remains valid the memory locations pointed to by buffers remains valid
until the completion handler is called. until the completion handler is called.
@throws boost::system::system_error Thrown on failure. @throws system_error Thrown on failure.
@note This function always sends an entire message. To @note This function always sends an entire message. To
send a message in fragments, use @ref write_frame. send a message in fragments, use @ref write_frame.
@ -1341,7 +1341,7 @@ public:
@param ec Set to indicate what error occurred, if any. @param ec Set to indicate what error occurred, if any.
@throws boost::system::system_error Thrown on failure. @throws system_error Thrown on failure.
@note This function always sends an entire message. To @note This function always sends an entire message. To
send a message in fragments, use @ref write_frame. send a message in fragments, use @ref write_frame.
@ -1426,7 +1426,7 @@ public:
@param buffers One or more buffers containing the frame's @param buffers One or more buffers containing the frame's
payload data. payload data.
@throws boost::system::system_error Thrown on failure. @throws system_error Thrown on failure.
*/ */
template<class ConstBufferSequence> template<class ConstBufferSequence>
void void
@ -1500,7 +1500,7 @@ public:
Copies will be made of the handler as required. The equivalent Copies will be made of the handler as required. The equivalent
function signature of the handler must be: function signature of the handler must be:
@code void handler( @code void handler(
boost::system::error_code const& error // result of operation error_code const& error // result of operation
); @endcode ); @endcode
*/ */
template<class ConstBufferSequence, class WriteHandler> template<class ConstBufferSequence, class WriteHandler>

View File

@ -59,7 +59,7 @@ public:
decltype(fs)&, streambuf> srs(fs); decltype(fs)&, streambuf> srs(fs);
srs.buffer().commit(buffer_copy( srs.buffer().commit(buffer_copy(
srs.buffer().prepare(5), buffer("Hello", 5))); srs.buffer().prepare(5), buffer("Hello", 5)));
boost::system::error_code ec; error_code ec;
boost::asio::read(srs, buffer(&s[0], s.size()), ec); boost::asio::read(srs, buffer(&s[0], s.size()), ec);
if(! ec) if(! ec)
{ {
@ -78,7 +78,7 @@ public:
srs.capacity(3); srs.capacity(3);
srs.buffer().commit(buffer_copy( srs.buffer().commit(buffer_copy(
srs.buffer().prepare(5), buffer("Hello", 5))); srs.buffer().prepare(5), buffer("Hello", 5)));
boost::system::error_code ec; error_code ec;
boost::asio::read(srs, buffer(&s[0], s.size()), ec); boost::asio::read(srs, buffer(&s[0], s.size()), ec);
if(! ec) if(! ec)
{ {
@ -96,7 +96,7 @@ public:
decltype(fs)&, streambuf> srs(fs); decltype(fs)&, streambuf> srs(fs);
srs.buffer().commit(buffer_copy( srs.buffer().commit(buffer_copy(
srs.buffer().prepare(5), buffer("Hello", 5))); srs.buffer().prepare(5), buffer("Hello", 5)));
boost::system::error_code ec; error_code ec;
boost::asio::async_read( boost::asio::async_read(
srs, buffer(&s[0], s.size()), do_yield[ec]); srs, buffer(&s[0], s.size()), do_yield[ec]);
if(! ec) if(! ec)
@ -116,7 +116,7 @@ public:
srs.capacity(3); srs.capacity(3);
srs.buffer().commit(buffer_copy( srs.buffer().commit(buffer_copy(
srs.buffer().prepare(5), buffer("Hello", 5))); srs.buffer().prepare(5), buffer("Hello", 5)));
boost::system::error_code ec; error_code ec;
boost::asio::async_read( boost::asio::async_read(
srs, buffer(&s[0], s.size()), do_yield[ec]); srs, buffer(&s[0], s.size()), do_yield[ec]);
if(! ec) if(! ec)

View File

@ -209,19 +209,19 @@ public:
p.on_body_rv(onBodyRv); p.on_body_rv(onBodyRv);
error_code ec; error_code ec;
p.write(buffer(s1.data(), s1.size()), ec); p.write(buffer(s1.data(), s1.size()), ec);
if(ec == test::fail_error) if(ec == test::error::fail_error)
continue; continue;
if(! BEAST_EXPECT(! ec)) if(! BEAST_EXPECT(! ec))
break; break;
if(! BEAST_EXPECT(s2.empty() || ! p.complete())) if(! BEAST_EXPECT(s2.empty() || ! p.complete()))
break; break;
p.write(buffer(s2.data(), s2.size()), ec); p.write(buffer(s2.data(), s2.size()), ec);
if(ec == test::fail_error) if(ec == test::error::fail_error)
continue; continue;
if(! BEAST_EXPECT(! ec)) if(! BEAST_EXPECT(! ec))
break; break;
p.write_eof(ec); p.write_eof(ec);
if(ec == test::fail_error) if(ec == test::error::fail_error)
continue; continue;
if(! BEAST_EXPECT(! ec)) if(! BEAST_EXPECT(! ec))
break; break;
@ -257,7 +257,7 @@ public:
p.on_body_rv(onBodyRv); p.on_body_rv(onBodyRv);
error_code ec; error_code ec;
p.write(buffer(s1.data(), s1.size()), ec); p.write(buffer(s1.data(), s1.size()), ec);
if(ec == test::fail_error) if(ec == test::error::fail_error)
continue; continue;
if(ec) if(ec)
{ {
@ -269,7 +269,7 @@ public:
if(! s2.empty()) if(! s2.empty())
{ {
p.write(buffer(s2.data(), s2.size()), ec); p.write(buffer(s2.data(), s2.size()), ec);
if(ec == test::fail_error) if(ec == test::error::fail_error)
continue; continue;
if(ec) if(ec)
{ {
@ -280,7 +280,7 @@ public:
break; break;
} }
p.write_eof(ec); p.write_eof(ec);
if(ec == test::fail_error) if(ec == test::error::fail_error)
continue; continue;
BEAST_EXPECT(! p.complete()); BEAST_EXPECT(! p.complete());
BEAST_EXPECT((ec && ! ev) || ec == ev); BEAST_EXPECT((ec && ! ev) || ec == ev);

View File

@ -174,7 +174,7 @@ public:
error_code ec; error_code ec;
auto const used = write(data, size, ec); auto const used = write(data, size, ec);
if(ec) if(ec)
throw boost::system::system_error{ec}; throw system_error{ec};
return used; return used;
} }
@ -189,7 +189,7 @@ public:
error_code ec; error_code ec;
auto const used = write(buffers, ec); auto const used = write(buffers, ec);
if(ec) if(ec)
throw boost::system::system_error{ec}; throw system_error{ec};
return used; return used;
} }
@ -204,7 +204,7 @@ public:
error_code ec; error_code ec;
write_eof(ec); write_eof(ec);
if(ec) if(ec)
throw boost::system::system_error{ec}; throw system_error{ec};
} }
void void

View File

@ -23,11 +23,13 @@ public:
BEAST_EXPECT(std::string{ec.category().name()} == name); BEAST_EXPECT(std::string{ec.category().name()} == name);
BEAST_EXPECT(! ec.message().empty()); BEAST_EXPECT(! ec.message().empty());
BEAST_EXPECT(std::addressof(ec.category()) == BEAST_EXPECT(std::addressof(ec.category()) ==
std::addressof(get_parse_error_category())); std::addressof(detail::get_parse_error_category()));
BEAST_EXPECT(get_parse_error_category().equivalent(static_cast<int>(ev), BEAST_EXPECT(detail::get_parse_error_category().equivalent(
ec.category().default_error_condition(static_cast<int>(ev)))); static_cast<std::underlying_type<parse_error>::type>(ev),
BEAST_EXPECT(get_parse_error_category().equivalent( ec.category().default_error_condition(
ec, static_cast<int>(ev))); static_cast<std::underlying_type<parse_error>::type>(ev))));
BEAST_EXPECT(detail::get_parse_error_category().equivalent(
ec, static_cast<std::underlying_type<parse_error>::type>(ev)));
} }
void run() override void run() override
@ -37,7 +39,6 @@ public:
check("http", parse_error::bad_uri); check("http", parse_error::bad_uri);
check("http", parse_error::bad_version); check("http", parse_error::bad_version);
check("http", parse_error::bad_crlf); check("http", parse_error::bad_crlf);
check("http", parse_error::bad_request);
check("http", parse_error::bad_status); check("http", parse_error::bad_status);
check("http", parse_error::bad_reason); check("http", parse_error::bad_reason);
check("http", parse_error::bad_field); check("http", parse_error::bad_field);

View File

@ -24,10 +24,12 @@ public:
BEAST_EXPECT(! ec.message().empty()); BEAST_EXPECT(! ec.message().empty());
BEAST_EXPECT(std::addressof(ec.category()) == BEAST_EXPECT(std::addressof(ec.category()) ==
std::addressof(detail::get_error_category())); std::addressof(detail::get_error_category()));
BEAST_EXPECT(detail::get_error_category().equivalent(static_cast<int>(ev),
ec.category().default_error_condition(static_cast<int>(ev))));
BEAST_EXPECT(detail::get_error_category().equivalent( BEAST_EXPECT(detail::get_error_category().equivalent(
ec, static_cast<int>(ev))); static_cast<std::underlying_type<error>::type>(ev),
ec.category().default_error_condition(
static_cast<std::underlying_type<error>::type>(ev))));
BEAST_EXPECT(detail::get_error_category().equivalent(
ec, static_cast<std::underlying_type<error>::type>(ev)));
} }
void run() override void run() override

View File

@ -816,7 +816,7 @@ public:
fail(); fail();
return false; return false;
} }
catch(boost::system::system_error const& se) catch(system_error const& se)
{ {
if(se.code() != ev) if(se.code() != ev)
throw; throw;