LIBWIRE
Next-generation C++17 networking library.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
error.hpp
Go to the documentation of this file.
1 /*
2  * Copyright © 2018 Max Mazurov (fox.cpp) <fox.cpp [at] disroot [dot] org>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20  * SOFTWARE.
21  */
22 
23 #pragma once
24 
25 #include <system_error>
26 
34 /*
35  * If you had to open this file to find answer for your question - we are so
36  * sorry. Please open issue with your question so we can update documentation
37  * to answer it.
38  */
39 
47 namespace libwire::error {
53  enum class generic : int8_t {
54  // Implementation note:
55  // Negative enum values forced to ensure
56  // no collisions with other codes.
57 
68  no_destination = -1,
69 
77  no_resources = -2,
78 
83  disconnected = -3,
84  };
85 
86  enum system_condition : uint8_t {
90  success = 0,
91 
98  unknown = 255,
99 
107  unexpected = 254,
108 
117 
133 
140 
146 
151 
156 
161 
166 
174 
182 
190 
196 
201 
206 
211 
217 
224 
229 
234 
239 
244 
249 
254 
259  };
260 
266 
272 
278  };
279 
280  std::error_condition make_error_condition(generic);
281  std::error_condition make_error_condition(system_condition);
282  std::error_condition make_error_condition(dns_condition);
283 
288  std::error_category& dns_category();
289 
294  std::error_category& system_category();
295 } // namespace libwire::error
296 
297 namespace std {
298  template<>
299  struct is_error_condition_enum<libwire::error::generic> : true_type {};
300 
301  template<>
302  struct is_error_condition_enum<libwire::error::system_condition> : true_type {};
303 
304  template<>
305  struct is_error_condition_enum<libwire::error::dns_condition> : true_type {};
306 } // namespace std
std::error_condition make_error_condition(generic)
Error code that should not occur on normal library operation.
Definition: error.hpp:107
Network is unreachable.
Definition: error.hpp:233
Requested host doesn't exists, but DNS server answer is non-authoritative.
Definition: error.hpp:271
Requested host exists, but does not have any addresses defined.
Definition: error.hpp:277
Reported by tcp::socket::connect to indicate that no service is listening on specified port...
Definition: error.hpp:195
Failed to connect to destination server.
Attempt to use not connected socket.
Definition: error.hpp:253
Underlying implementation reported temporary failure -OR- non-blocking operation would block...
Definition: error.hpp:145
Reported by listener::bind to indicate that interface with specified address doesn't exists or not lo...
Definition: error.hpp:223
Non-blocking operation started, but not completed yet.
Definition: error.hpp:150
Previous non-blocking operation still running.
Definition: error.hpp:155
Reported by listener::bind or listen to indicate that port is already used.
Definition: error.hpp:216
generic
These values combine together different error codes to simplify error handling where reaction to diff...
Definition: error.hpp:53
Operating system out of memory.
Definition: error.hpp:165
System call interrupted by signal (POSIX-specific).
Definition: error.hpp:160
Host destination is unreachable.
Definition: error.hpp:243
A connection has been aborted.
Definition: error.hpp:228
Timed out while trying to perform operation.
Definition: error.hpp:248
std::error_category & system_category()
Obtain reference to static instance of category for various network and socket errors.
Invalid argument passed to function.
Definition: error.hpp:116
Destination finished transmission.
Definition: error.hpp:205
Error code not mapped to any other condition.
Definition: error.hpp:98
RST segment received (TCP).
Definition: error.hpp:200
Per-process limitation reached.
Definition: error.hpp:173
Requested protocol is not supported.
Definition: error.hpp:189
Host is known to be down.
Definition: error.hpp:238
Operation completed successfully.
Definition: error.hpp:90
Cannot send after transport endpoint shutdown.
Definition: error.hpp:210
Remote side of connection finished transmission.
Definition: error.hpp:258
Disconnected, either forcibly or gracefully.
std::error_category & dns_category()
Obtain reference to static instance of category for DNS errors.
Requested host doesn't exists.
Definition: error.hpp:265
Access to resource disallowed.
Definition: error.hpp:132
System-wide limitation reached.
Definition: error.hpp:181