Nexus HTTP/3
A QUIC and HTTP/3 library
error.hpp
1 #pragma once
2 
3 #include <nexus/error_code.hpp>
4 
5 namespace nexus::quic {
6 
8 enum class connection_error {
10  aborted = 1,
14  timed_out,
16  reset,
18  going_away,
21 };
22 
24 const error_category& connection_category();
25 
26 inline error_code make_error_code(connection_error e)
27 {
28  return {static_cast<int>(e), connection_category()};
29 }
30 inline error_condition make_error_condition(connection_error e)
31 {
32  return {static_cast<int>(e), connection_category()};
33 }
34 
35 
37 enum class stream_error {
39  eof = 1,
41  busy,
43  aborted,
45  reset,
46 };
47 
49 const error_category& stream_category();
50 
51 inline error_code make_error_code(stream_error e)
52 {
53  return {static_cast<int>(e), stream_category()};
54 }
55 inline error_condition make_error_condition(stream_error e)
56 {
57  return {static_cast<int>(e), stream_category()};
58 }
59 
60 
62 enum class transport_error {
63  no_error = 0x0,
64  internal_error = 0x1,
65  connection_refused = 0x2,
66  flow_control_error = 0x3,
67  stream_limit_error = 0x4,
68  stream_state_error = 0x5,
69  final_size_error = 0x6,
70  frame_encoding_error = 0x7,
71  transport_parameter_error = 0x8,
72  connection_id_limit_error = 0x9,
73  protocol_violation = 0xa,
74  invalid_token = 0xb,
75  application_error = 0xc,
76  crypto_buffer_exceeded = 0xd,
77  key_update_error = 0xe,
78  aead_limit_reached = 0xf,
79  no_viable_path = 0x10,
80 };
81 
83 const error_category& transport_category();
84 
85 inline error_code make_error_code(transport_error e)
86 {
87  return {static_cast<int>(e), transport_category()};
88 }
89 inline error_condition make_error_condition(transport_error e)
90 {
91  return {static_cast<int>(e), transport_category()};
92 }
93 
94 
96 enum class tls_alert : uint8_t {
97  close_notify = 0,
98  unexpected_message = 10,
99  bad_record_mac = 20,
100  record_overflow = 22,
101  handshake_failure = 40,
102  bad_certificate = 42,
103  unsupported_certificate = 43,
104  certificate_revoked = 44,
105  certificate_expired = 45,
106  certificate_unknown = 46,
107  illegal_parameter = 47,
108  unknown_ca = 48,
109  access_denied = 49,
110  decode_error = 50,
111  decrypt_error = 51,
112  protocol_version = 70,
113  insufficient_security = 71,
114  internal_error = 80,
115  inappropriate_fallback = 86,
116  user_canceled = 90,
117  missing_extension = 109,
118  unsupported_extension = 110,
119  unrecognized_name = 112,
120  bad_certificate_status_response = 113,
121  unknown_psk_identity = 115,
122  certificate_required = 116,
123  no_application_protocol = 120,
124 };
125 
127 const error_category& tls_category();
128 
129 inline error_code make_error_code(tls_alert e)
130 {
131  return {static_cast<int>(e), tls_category()};
132 }
133 inline error_condition make_error_condition(tls_alert e)
134 {
135  return {static_cast<int>(e), tls_category()};
136 }
137 
138 
140 const error_category& application_category();
141 
142 } // namespace nexus::quic
143 
144 namespace SYSTEM_ERROR_NAMESPACE {
145 
147 template <>
148 struct is_error_code_enum<nexus::quic::connection_error> : public std::true_type {};
149 template <>
150 struct is_error_code_enum<nexus::quic::stream_error> : public std::true_type {};
151 template <>
152 struct is_error_code_enum<nexus::quic::transport_error> : public std::true_type {};
153 template <>
154 struct is_error_code_enum<nexus::quic::tls_alert> : public std::true_type {};
155 
156 } // namespace SYSTEM_ERROR_NAMESPACE
Generic QUIC library.
Definition: client.hpp:8
stream_error
quic stream errors
Definition: error.hpp:37
@ eof
no more bytes can be read because the peer closed the stream for writing
@ reset
stream reset by peer
@ busy
stream cannot process more than one read or more than one write at a time
@ aborted
this end of the stream was closed
const error_category & transport_category()
transport error category
connection_error
quic connection errors
Definition: error.hpp:8
@ going_away
sent GOAWAY to peer
@ timed_out
the connection or handshake timed out
@ reset
connection reset by peer
@ peer_going_away
peer sent GOAWAY
@ aborted
this end of the connection was closed
@ handshake_failed
the connection's tls handshake failed
const error_category & application_category()
application-level error category
transport_error
quic transport error codes sent in CONNECTION_CLOSE frames
Definition: error.hpp:62
const error_category & connection_category()
connection error category
tls_alert
tls alerts
Definition: error.hpp:96
const error_category & stream_category()
stream error category
const error_category & tls_category()
tls error category
networking
Definition: error_code.hpp:8