-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy patherror.cpp
More file actions
107 lines (93 loc) · 2.47 KB
/
Copy patherror.cpp
File metadata and controls
107 lines (93 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//
// Copyright (c) 2026 Mohammad Nejati
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/cppalliance/burl
//
#include <boost/burl/error.hpp>
#include <boost/http/status.hpp>
namespace boost
{
namespace burl
{
char const*
error_category::name() const noexcept
{
return "boost.burl";
}
std::string
error_category::message(int ev) const
{
if(ev >= 400 && ev < 600)
{
auto status = static_cast<http::status>(ev);
return "HTTP " + std::to_string(ev) + " " +
std::string(http::to_string(status));
}
switch(static_cast<error>(ev))
{
case error::unsupported_url_scheme:
return "unsupported URL scheme";
case error::too_many_redirects:
return "too many redirects";
case error::bad_redirect_response:
return "bad redirect response";
case error::file_changed:
return "file size changed during read";
case error::unsupported_proxy_scheme:
return "unsupported proxy scheme";
case error::proxy_connect_failed:
return "proxy could not connect to the target";
case error::proxy_auth_failed:
return "proxy authentication failed";
case error::proxy_unsupported_version:
return "unsupported proxy protocol version";
default:
return "unknown error";
}
}
std::error_condition
error_category::default_error_condition(int ev) const noexcept
{
if(ev >= 400 && ev < 500)
return condition::client_error;
if(ev >= 500 && ev < 600)
return condition::server_error;
return std::error_condition(ev, *this);
}
//----------------------------------------------------------
char const*
condition_category::name() const noexcept
{
return "boost.burl.condition";
}
std::string
condition_category::message(int ev) const
{
switch(static_cast<condition>(ev))
{
case condition::client_error:
return "HTTP client error";
case condition::server_error:
return "HTTP server error";
default:
return "unknown condition";
}
}
//----------------------------------------------------------
std::error_category const&
burl_category() noexcept
{
static error_category const cat{};
return cat;
}
std::error_category const&
burl_condition_category() noexcept
{
static condition_category const cat{};
return cat;
}
} // namespace burl
} // namespace boost