-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy patherrors.go
More file actions
58 lines (46 loc) · 1.53 KB
/
Copy patherrors.go
File metadata and controls
58 lines (46 loc) · 1.53 KB
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
package desync
import "fmt"
// ChunkMissing is returned by a store that can't find a requested chunk
type ChunkMissing struct {
ID ChunkID
}
// NoSuchObject is returned by a store that can't find a requested object
type NoSuchObject struct {
location string
}
func (e ChunkMissing) Error() string {
return fmt.Sprintf("chunk %s missing from store", e.ID.String())
}
func (e NoSuchObject) Error() string {
return fmt.Sprintf("object %s missing from store", e.location)
}
// ChunkInvalid means the chunk failed validation, either because the hash
// of its content doesn't match its ID, or because the storage data couldn't
// be converted to plain data in the first place, for example when
// decryption or decompression fails. In the latter case Err holds the
// conversion error.
type ChunkInvalid struct {
ID ChunkID
Sum ChunkID
Err error
}
func (e ChunkInvalid) Error() string {
if e.Err != nil {
return fmt.Sprintf("invalid chunk %s: %s", e.ID.String(), e.Err)
}
return fmt.Sprintf("chunk id %s does not match its hash %s", e.ID.String(), e.Sum.String())
}
func (e ChunkInvalid) Unwrap() error {
return e.Err
}
// InvalidFormat is returned when an error occurred when parsing an archive file
type InvalidFormat struct {
Msg string
}
func (e InvalidFormat) Error() string {
return fmt.Sprintf("invalid archive format : %s", e.Msg)
}
// Interrupted is returned when a user interrupted a long-running operation, for
// example by pressing Ctrl+C
type Interrupted struct{}
func (e Interrupted) Error() string { return "interrupted" }