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 committed 2018-01-01 13:38:55 -08:00
1 parent b86169019e
commit 08a9ed4c25
5 files changed
+116 -9

No files matched your search

+38 -2
View File
@@ -18,9 +18,9 @@ namespace detail {
template<class>
string_view
error_codes::
get_message(error ev) const
message(error e) const
{
switch(ev)
switch(e)
{
default:
case error::failed: return "WebSocket connection failed due to a protocol violation";
@@ -31,6 +31,42 @@ get_message(error ev) const
}
}
template<class>
string_view
error_conditions::
message(condition c) const
{
switch(c)
{
default:
case condition::handshake_failed: return "WebSocket upgrade handshake failed";
}
}
template<class>
bool
error_conditions::
equivalent(
error_code const& ec,
condition c) const noexcept
{
if(ec.category() == error_code{error{}}.category())
{
switch(c)
{
case condition::handshake_failed:
switch(static_cast<error>(ec.value()))
{
case error::handshake_failed:
return true;
}
return false;
}
}
return false;
}
} // detail
} // websocket
} // beast