blob: b718cff586302c273c92ae8dea09c3d89470391e (
plain)
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
|
// Copyright 2013-2016 Glyn Matthews.
// 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)
#include <string>
#include <network/uri/uri_errors.hpp>
namespace network {
class uri_category_impl : public std::error_category {
public:
uri_category_impl() = default;
virtual ~uri_category_impl() noexcept;
virtual const char *name() const noexcept;
virtual std::string message(int ev) const;
};
uri_category_impl::~uri_category_impl() noexcept {}
const char *uri_category_impl::name() const noexcept {
static const char name[] = "uri_error";
return name;
}
std::string uri_category_impl::message(int ev) const {
switch (uri_error(ev)) {
case uri_error::invalid_syntax:
return "Unable to parse URI string.";
case uri_error::not_enough_input:
return "Percent decoding: Not enough input.";
case uri_error::non_hex_input:
return "Percent decoding: Non-hex input.";
case uri_error::conversion_failed:
return "Percent decoding: Conversion failed.";
default:
break;
}
return "Unknown URI error.";
}
const std::error_category &uri_category() {
static uri_category_impl uri_category;
return uri_category;
}
std::error_code make_error_code(uri_error e) {
return std::error_code(static_cast<int>(e), uri_category());
}
uri_syntax_error::uri_syntax_error()
: std::system_error(make_error_code(uri_error::invalid_syntax)) {}
uri_syntax_error::~uri_syntax_error() noexcept {}
uri_builder_error::uri_builder_error()
: std::system_error(make_error_code(uri_error::invalid_uri)) {}
uri_builder_error::~uri_builder_error() noexcept {}
percent_decoding_error::percent_decoding_error(uri_error error)
: std::system_error(make_error_code(error)) {}
percent_decoding_error::~percent_decoding_error() noexcept {}
} // namespace network
|