-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.go
48 lines (41 loc) · 929 Bytes
/
error.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
package option
const (
//ErrorTypeDownload download error type
ErrorTypeDownload = "download"
//ErrorTypeUpload upload error type
ErrorTypeUpload = "upload"
//ErrorTypeReader reader error type
ErrorTypeReader = "reader"
)
//Error represents a simulation error
type Error struct {
Type string
Error error
}
//Errors represents simulation errors
type Errors []*Error
//NewUploadError creates an upload error
func NewUploadError(err error) *Error {
return &Error{
Type: ErrorTypeUpload,
Error: err,
}
}
//NewDownloadError creates a download error
func NewDownloadError(err error) *Error {
return &Error{
Type: ErrorTypeDownload,
Error: err,
}
}
//NewReaderError creates a reader error
func NewReaderError(err error) *Error {
return &Error{
Type: ErrorTypeReader,
Error: err,
}
}
//NewErrors creates an error slice for supplied errors
func NewErrors(errors ...*Error) []*Error {
return errors
}