]> git.proxmox.com Git - ceph.git/blob - ceph/src/crimson/net/Errors.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / crimson / net / Errors.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2017 Red Hat, Inc
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 *
13 */
14
15 #pragma once
16
17 #include <system_error>
18
19 namespace crimson::net {
20
21 /// net error codes
22 enum class error {
23 success = 0,
24 bad_connect_banner,
25 bad_peer_address,
26 negotiation_failure,
27 read_eof,
28 corrupted_message,
29 protocol_aborted,
30 };
31
32 /// net error category
33 const std::error_category& net_category();
34
35 inline std::error_code make_error_code(error e)
36 {
37 return {static_cast<int>(e), net_category()};
38 }
39
40 inline std::error_condition make_error_condition(error e)
41 {
42 return {static_cast<int>(e), net_category()};
43 }
44
45 } // namespace crimson::net
46
47 namespace std {
48
49 /// enables implicit conversion to std::error_condition
50 template <>
51 struct is_error_condition_enum<crimson::net::error> : public true_type {};
52
53 } // namespace std