Line data Source code
1 : #include "client_error.hpp"
2 : #include <string>
3 :
4 : namespace thinger::http {
5 :
6 : namespace {
7 :
8 : class client_error_category_impl : public boost::system::error_category {
9 : public:
10 0 : const char* name() const noexcept override {
11 0 : return "thinger.http.client";
12 : }
13 :
14 615 : std::string message(int value) const override {
15 615 : switch (static_cast<client_error>(value)) {
16 0 : case client_error::none: return "success";
17 315 : case client_error::invalid_status_line: return "invalid response status line";
18 117 : case client_error::invalid_header: return "invalid response header";
19 0 : case client_error::header_section_too_large: return "response header section too large";
20 540 : case client_error::invalid_framing: return "invalid response framing (Content-Length or Transfer-Encoding)";
21 189 : case client_error::malformed_body: return "malformed chunked response body";
22 0 : case client_error::body_too_large: return "response body too large";
23 504 : case client_error::incomplete_response: return "connection closed before the end of the response";
24 36 : case client_error::unexpected_upgrade: return "unexpected protocol switch (101) without Upgrade in the request";
25 126 : case client_error::aborted: return "download aborted";
26 0 : case client_error::invalid_ca_certificate: return "a CA certificate could not be loaded";
27 18 : case client_error::proxy_authentication_required: return "proxy authentication required (407 to CONNECT)";
28 0 : case client_error::proxy_tunnel_failed: return "the proxy did not open a tunnel to the origin (CONNECT)";
29 0 : case client_error::invalid_proxy: return "invalid or unsupported proxy URL";
30 0 : case client_error::bad_content_encoding: return "the response body could not be decoded as its Content-Encoding says";
31 0 : case client_error::invalid_client_certificate: return "the client certificate could not be read";
32 0 : case client_error::invalid_client_key: return "the private key of the client certificate could not be read";
33 0 : case client_error::client_key_mismatch: return "the private key is not the one of the client certificate";
34 : }
35 0 : return "unknown client error";
36 : }
37 : };
38 :
39 : }
40 :
41 813 : const boost::system::error_category& client_error_category() {
42 : static const client_error_category_impl category;
43 813 : return category;
44 : }
45 :
46 : }
|