Add WebSocket error conditions:

This introduces the condition enumeration type for grouping
websocket error codes together as a convenience to callers.
This commit is contained in:
Vinnie Falco
2018-01-01 13:38:55 -08:00
parent b86169019e
commit 08a9ed4c25
5 changed files with 116 additions and 9 deletions
+12 -5
View File
@@ -20,23 +20,28 @@ namespace websocket {
class error_test : public unit_test::suite
{
public:
void check(error ev)
void check(error e)
{
auto const ec = make_error_code(ev);
auto const ec = make_error_code(e);
ec.category().name();
BEAST_EXPECT(! ec.message().empty());
#if 0
BEAST_EXPECT(std::addressof(ec.category()) ==
std::addressof(detail::get_error_category()));
BEAST_EXPECT(detail::get_error_category().equivalent(
static_cast<std::underlying_type<error>::type>(ev),
static_cast<std::underlying_type<error>::type>(e),
ec.category().default_error_condition(
static_cast<std::underlying_type<error>::type>(ev))));
static_cast<std::underlying_type<error>::type>(e))));
BEAST_EXPECT(detail::get_error_category().equivalent(
ec, static_cast<std::underlying_type<error>::type>(ev)));
ec, static_cast<std::underlying_type<error>::type>(e)));
#endif
}
void check(error e, condition c)
{
BEAST_EXPECT(error_code{e} == c);
}
void run() override
{
check(error::closed);
@@ -44,6 +49,8 @@ public:
check(error::handshake_failed);
check(error::buffer_overflow);
check(error::partial_deflate_block);
check(error::handshake_failed, condition::handshake_failed);
}
};