-
Notifications
You must be signed in to change notification settings - Fork 5
/
stream_err.go
85 lines (70 loc) · 1.31 KB
/
stream_err.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package main
import (
"fmt"
"io"
)
type writeError struct {
Err error
}
func (err *writeError) Error() string {
return fmt.Sprintf("write: %v", err.Err)
}
func (err *writeError) Unwrap() error {
return err.Err
}
type writerError struct {
w io.Writer
}
func (w *writerError) Write(p []byte) (int, error) {
n, err := w.w.Write(p)
if err != nil {
return n, &writeError{err}
}
return n, nil
}
type readError struct {
Err error
}
func (err *readError) Error() string {
return fmt.Sprintf("read: %v", err.Err)
}
func (err *readError) Unwrap() error {
return err.Err
}
type readerError struct {
r io.Reader
}
func (r *readerError) Read(p []byte) (int, error) {
n, err := r.r.Read(p)
if err != nil {
return n, &readError{err}
}
return n, nil
}
type retryError struct {
Err error
}
func (err *retryError) Error() string {
return fmt.Sprintf("retrying segment: %v", err.Err)
}
func (err *retryError) Unwrap() error {
return err.Err
}
type skipError struct {
Err error
}
func (err *skipError) Error() string {
return fmt.Sprintf("skipping segment: %v", err.Err)
}
func (err *skipError) Unwrap() error {
return err.Err
}
type fatalError struct {
Err error
}
func (err *fatalError) Error() string {
return fmt.Sprintf("fatal error: %v", err.Err)
}
func (err *fatalError) Unwrap() error {
return err.Err
}