src/error.cpp
96.2% Lines (50/52)
100.0% List of functions (7/7)
90.6% Branches (48/53)
Functions (7)
Function
Calls
Lines
Branches
Blocks
boost::burl::error_category::name() const
:20
1x
100.0%
–
100.0%
boost::burl::error_category::message[abi:cxx11](int) const
:26
14x
92.9%
93.5%
57.0%
boost::burl::error_category::default_error_condition(int) const
:63
15x
100.0%
87.5%
100.0%
boost::burl::condition_category::name() const
:75
1x
100.0%
–
100.0%
boost::burl::condition_category::message[abi:cxx11](int) const
:81
3x
100.0%
100.0%
69.0%
boost::burl::burl_category()
:97
86x
100.0%
75.0%
100.0%
boost::burl::burl_condition_category()
:104
22x
100.0%
75.0%
100.0%
| Line | Branch | TLA | Hits | Source Code |
|---|---|---|---|---|
| 1 | // | |||
| 2 | // Copyright (c) 2026 Mohammad Nejati | |||
| 3 | // | |||
| 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) | |||
| 6 | // | |||
| 7 | // Official repository: https://github.com/cppalliance/burl | |||
| 8 | // | |||
| 9 | ||||
| 10 | #include <boost/burl/error.hpp> | |||
| 11 | ||||
| 12 | #include <boost/http/status.hpp> | |||
| 13 | ||||
| 14 | namespace boost | |||
| 15 | { | |||
| 16 | namespace burl | |||
| 17 | { | |||
| 18 | ||||
| 19 | char const* | |||
| 20 | 1x | error_category::name() const noexcept | ||
| 21 | { | |||
| 22 | 1x | return "boost.burl"; | ||
| 23 | } | |||
| 24 | ||||
| 25 | std::string | |||
| 26 | 14x | error_category::message(int ev) const | ||
| 27 | { | |||
| 28 |
4/4✓ Branch 0 taken 5 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 time.
|
14x | if(ev >= 400 && ev < 600) | |
| 29 | { | |||
| 30 | 4x | auto status = static_cast<http::status>(ev); | ||
| 31 |
2/2✓ Branch 2 taken 4 times.
✓ Branch 5 taken 4 times.
|
8x | return "HTTP " + std::to_string(ev) + " " + | |
| 32 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
12x | std::string(http::to_string(status)); | |
| 33 | } | |||
| 34 | ||||
| 35 |
10/11✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 1 time.
✓ Branch 6 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 time.
|
10x | switch(static_cast<error>(ev)) | |
| 36 | { | |||
| 37 | 1x | case error::unsupported_url_scheme: | ||
| 38 |
1/1✓ Branch 1 taken 1 time.
|
2x | return "unsupported URL scheme"; | |
| 39 | 1x | case error::too_many_redirects: | ||
| 40 |
1/1✓ Branch 1 taken 1 time.
|
2x | return "too many redirects"; | |
| 41 | 1x | case error::bad_redirect_response: | ||
| 42 |
1/1✓ Branch 1 taken 1 time.
|
2x | return "bad redirect response"; | |
| 43 | 1x | case error::file_changed: | ||
| 44 |
1/1✓ Branch 1 taken 1 time.
|
2x | return "file size changed during read"; | |
| 45 | 1x | case error::unsupported_proxy_scheme: | ||
| 46 |
1/1✓ Branch 1 taken 1 time.
|
2x | return "unsupported proxy scheme"; | |
| 47 | 1x | case error::proxy_connect_failed: | ||
| 48 |
1/1✓ Branch 1 taken 1 time.
|
2x | return "proxy could not connect to the target"; | |
| 49 | 1x | case error::proxy_auth_failed: | ||
| 50 |
1/1✓ Branch 1 taken 1 time.
|
2x | return "proxy authentication failed"; | |
| 51 | 1x | case error::proxy_unsupported_version: | ||
| 52 |
1/1✓ Branch 1 taken 1 time.
|
2x | return "unsupported proxy protocol version"; | |
| 53 | 1x | case error::body_size_mismatch: | ||
| 54 |
1/1✓ Branch 1 taken 1 time.
|
2x | return "request body size did not match content length"; | |
| 55 | ✗ | case error::decode_error: | ||
| 56 | ✗ | return "response body could not be decoded"; | ||
| 57 | 1x | default: | ||
| 58 |
1/1✓ Branch 1 taken 1 time.
|
2x | return "unknown error"; | |
| 59 | } | |||
| 60 | } | |||
| 61 | ||||
| 62 | std::error_condition | |||
| 63 | 15x | error_category::default_error_condition(int ev) const noexcept | ||
| 64 | { | |||
| 65 |
4/4✓ Branch 0 taken 8 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
|
15x | if(ev >= 400 && ev < 500) | |
| 66 | 4x | return condition::client_error; | ||
| 67 |
3/4✓ Branch 0 taken 4 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
11x | if(ev >= 500 && ev < 600) | |
| 68 | 4x | return condition::server_error; | ||
| 69 | 7x | return std::error_condition(ev, *this); | ||
| 70 | } | |||
| 71 | ||||
| 72 | //---------------------------------------------------------- | |||
| 73 | ||||
| 74 | char const* | |||
| 75 | 1x | condition_category::name() const noexcept | ||
| 76 | { | |||
| 77 | 1x | return "boost.burl.condition"; | ||
| 78 | } | |||
| 79 | ||||
| 80 | std::string | |||
| 81 | 3x | condition_category::message(int ev) const | ||
| 82 | { | |||
| 83 |
3/3✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 1 time.
|
3x | switch(static_cast<condition>(ev)) | |
| 84 | { | |||
| 85 | 1x | case condition::client_error: | ||
| 86 |
1/1✓ Branch 1 taken 1 time.
|
2x | return "HTTP client error"; | |
| 87 | 1x | case condition::server_error: | ||
| 88 |
1/1✓ Branch 1 taken 1 time.
|
2x | return "HTTP server error"; | |
| 89 | 1x | default: | ||
| 90 |
1/1✓ Branch 1 taken 1 time.
|
2x | return "unknown condition"; | |
| 91 | } | |||
| 92 | } | |||
| 93 | ||||
| 94 | //---------------------------------------------------------- | |||
| 95 | ||||
| 96 | std::error_category const& | |||
| 97 | 86x | burl_category() noexcept | ||
| 98 | { | |||
| 99 |
3/4✓ Branch 0 taken 10 times.
✓ Branch 1 taken 76 times.
✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
|
86x | static error_category const cat{}; | |
| 100 | 86x | return cat; | ||
| 101 | } | |||
| 102 | ||||
| 103 | std::error_category const& | |||
| 104 | 22x | burl_condition_category() noexcept | ||
| 105 | { | |||
| 106 |
3/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 20 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
22x | static condition_category const cat{}; | |
| 107 | 22x | return cat; | ||
| 108 | } | |||
| 109 | ||||
| 110 | } // namespace burl | |||
| 111 | } // namespace boost | |||
| 112 |