-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.go
60 lines (44 loc) · 1.17 KB
/
errors.go
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
package quack
import (
"fmt"
)
const (
QpackDecompressionFailed = 0x0200
QpackEncoderStreamError = 0x0201
QpackDecoderStreamError = 0x0202
)
// https://www.rfc-editor.org/rfc/rfc9204.html#name-error-handling
type Error interface {
error
ErrorCode() uint16
}
type ErrDecompressionFailed struct {
err error
}
func (e ErrDecompressionFailed) ErrorCode() uint16 { return QpackDecompressionFailed }
func (e ErrDecompressionFailed) Unwrap() error {
return e.err
}
func (e ErrDecompressionFailed) Error() string {
return fmt.Sprintf("qpack: decompression failed: %s", e.err.Error())
}
type ErrEncoderStream struct {
err error
}
func (e ErrEncoderStream) ErrorCode() uint16 { return QpackEncoderStreamError }
func (e ErrEncoderStream) Unwrap() error {
return e.err
}
func (e ErrEncoderStream) Error() string {
return fmt.Sprintf("qpack: encoder stream error: %s", e.err.Error())
}
type ErrDecoderStream struct {
err error
}
func (e ErrDecoderStream) ErrorCode() uint16 { return QpackDecoderStreamError }
func (e ErrDecoderStream) Unwrap() error {
return e.err
}
func (e ErrDecoderStream) Error() string {
return fmt.Sprintf("qpack: decoder stream error: %s", e.err.Error())
}