1
2
3
4
5 package http3
6
7 import "fmt"
8
9
10 type http3Error int
11
12 const (
13
14 errH3NoError = http3Error(0x0100)
15 errH3GeneralProtocolError = http3Error(0x0101)
16 errH3InternalError = http3Error(0x0102)
17 errH3StreamCreationError = http3Error(0x0103)
18 errH3ClosedCriticalStream = http3Error(0x0104)
19 errH3FrameUnexpected = http3Error(0x0105)
20 errH3FrameError = http3Error(0x0106)
21 errH3ExcessiveLoad = http3Error(0x0107)
22 errH3IDError = http3Error(0x0108)
23 errH3SettingsError = http3Error(0x0109)
24 errH3MissingSettings = http3Error(0x010a)
25 errH3RequestRejected = http3Error(0x010b)
26 errH3RequestCancelled = http3Error(0x010c)
27 errH3RequestIncomplete = http3Error(0x010d)
28 errH3MessageError = http3Error(0x010e)
29 errH3ConnectError = http3Error(0x010f)
30 errH3VersionFallback = http3Error(0x0110)
31
32
33 errQPACKDecompressionFailed = http3Error(0x0200)
34 errQPACKEncoderStreamError = http3Error(0x0201)
35 errQPACKDecoderStreamError = http3Error(0x0202)
36 )
37
38 func (e http3Error) Error() string {
39 switch e {
40 case errH3NoError:
41 return "H3_NO_ERROR"
42 case errH3GeneralProtocolError:
43 return "H3_GENERAL_PROTOCOL_ERROR"
44 case errH3InternalError:
45 return "H3_INTERNAL_ERROR"
46 case errH3StreamCreationError:
47 return "H3_STREAM_CREATION_ERROR"
48 case errH3ClosedCriticalStream:
49 return "H3_CLOSED_CRITICAL_STREAM"
50 case errH3FrameUnexpected:
51 return "H3_FRAME_UNEXPECTED"
52 case errH3FrameError:
53 return "H3_FRAME_ERROR"
54 case errH3ExcessiveLoad:
55 return "H3_EXCESSIVE_LOAD"
56 case errH3IDError:
57 return "H3_ID_ERROR"
58 case errH3SettingsError:
59 return "H3_SETTINGS_ERROR"
60 case errH3MissingSettings:
61 return "H3_MISSING_SETTINGS"
62 case errH3RequestRejected:
63 return "H3_REQUEST_REJECTED"
64 case errH3RequestCancelled:
65 return "H3_REQUEST_CANCELLED"
66 case errH3RequestIncomplete:
67 return "H3_REQUEST_INCOMPLETE"
68 case errH3MessageError:
69 return "H3_MESSAGE_ERROR"
70 case errH3ConnectError:
71 return "H3_CONNECT_ERROR"
72 case errH3VersionFallback:
73 return "H3_VERSION_FALLBACK"
74 case errQPACKDecompressionFailed:
75 return "QPACK_DECOMPRESSION_FAILED"
76 case errQPACKEncoderStreamError:
77 return "QPACK_ENCODER_STREAM_ERROR"
78 case errQPACKDecoderStreamError:
79 return "QPACK_DECODER_STREAM_ERROR"
80 }
81 return fmt.Sprintf("H3_ERROR_%v", int(e))
82 }
83
84
85
86 type streamError struct {
87 code http3Error
88 message string
89 }
90
91 func (e *streamError) Error() string { return e.message }
92 func (e *streamError) Unwrap() error { return e.code }
93
94
95
96 type connectionError struct {
97 code http3Error
98 message string
99 }
100
101 func (e *connectionError) Error() string { return e.message }
102 func (e *connectionError) Unwrap() error { return e.code }
103
View as plain text