File Coverage

src/panda/protocol/websocket/Error.cc
Criterion Covered Total %
statement 19 30 63.3
branch 15 54 27.7
condition n/a
subroutine n/a
pod n/a
total 34 84 40.4


line stmt bran cond sub pod time code
1             #include "Error.h"
2             #include
3             #include
4              
5             namespace panda { namespace protocol { namespace websocket {
6              
7 18 50         log::Module panda_log_module("Protocol::WebSocket", log::WARNING);
8              
9 18           const std::error_category& error_category = ErrorCategory();
10              
11 142           const char* ErrorCategory::name () const noexcept { return "protocol-websocket"; }
12              
13 70           std::string ErrorCategory::message (int ev) const {
14 70           switch (errc(ev)) {
15 0 0         case errc::garbage_after_connect : return "garbage found after http request";
16 0 0         case errc::response_code_101 : return "handshake response code must be 101";
17 0 0         case errc::unsupported_version : return "client's Sec-WebSocket-Version is not supported";
18 0 0         case errc::connection_mustbe_upgrade : return "Connection must be 'Upgrade'";
19 2 50         case errc::upgrade_mustbe_websocket : return "Upgrade must be 'websocket'";
20 0 0         case errc::sec_accept_missing : return "Sec-WebSocket-Accept missing or invalid";
21 1 50         case errc::method_mustbe_get : return "method must be GET";
22 0 0         case errc::http_1_1_required : return "HTTP/1.1 or higher required";
23 0 0         case errc::body_prohibited : return "body must not present";
24 10 50         case errc::invalid_opcode : return "invalid opcode received";
25 12 50         case errc::control_fragmented : return "control frame can't be fragmented";
26 12 50         case errc::control_payload_too_big : return "control frame payload is too big";
27 4 50         case errc::not_masked : return "frame is not masked";
28 2 50         case errc::max_frame_size : return "max frame size exceeded";
29 18 50         case errc::close_frame_invalid_data : return "control frame CLOSE contains invalid data";
30 4 50         case errc::initial_continue : return "initial frame can't have opcode CONTINUE";
31 0 0         case errc::fragment_no_continue : return "fragment frame must have opcode CONTINUE";
32 2 50         case errc::max_message_size : return "max message size exceeded";
33 0 0         case errc::deflate_negotiation_failed : return "deflate parameters negotiation error";
34 1 50         case errc::control_frame_compression : return "compression of control frames is not allowed";
35 2 50         case errc::inflate_error : return "zlib::inflate error";
36 0 0         case errc::unexpected_rsv : return "RSV is set but no extension defining RSV meaning has been negotiated";
37 0 0         case errc::invalid_utf8 : return "invalid utf8 sequence";
38             }
39 70 0         return "unknown error";
40             }
41              
42 72 50         }}}
    50