2 // Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // Official repository: https://github.com/boostorg/beast
10 #ifndef BOOST_BEAST_WEBSOCKET_IMPL_ERROR_IPP
11 #define BOOST_BEAST_WEBSOCKET_IMPL_ERROR_IPP
17 struct is_error_code_enum<beast::websocket::error>
19 static bool const value = true;
27 class websocket_error_category : public error_category
31 name() const noexcept override
33 return "boost.beast.websocket";
37 message(int ev) const override
39 switch(static_cast<error>(ev))
42 case error::failed: return "WebSocket connection failed due to a protocol violation";
43 case error::closed: return "WebSocket connection closed normally";
44 case error::handshake_failed: return "WebSocket upgrade handshake failed";
45 case error::buffer_overflow: return "WebSocket dynamic buffer overflow";
46 case error::partial_deflate_block: return "WebSocket partial deflate block";
51 default_error_condition(int ev) const noexcept override
53 return error_condition(ev, *this);
58 error_condition const& condition
59 ) const noexcept override
61 return condition.value() == ev &&
62 &condition.category() == this;
66 equivalent(error_code const& error, int ev) const noexcept override
68 return error.value() == ev &&
69 &error.category() == this;
77 static detail::websocket_error_category const cat{};
85 make_error_code(error e)
88 static_cast<std::underlying_type<error>::type>(e),
89 detail::get_error_category());