| 1 |
package desync |
| 2 |
|
| 3 |
import "fmt" |
| 4 |
|
| 5 |
// ChunkMissing is returned by a store that can't find a requested chunk |
| 6 |
type ChunkMissing struct { |
| 7 |
ID ChunkID |
| 8 |
} |
| 9 |
|
| 10 |
// NoSuchObject is returned by a store that can't find a requested object |
| 11 |
type NoSuchObject struct { |
| 12 |
location string |
| 13 |
} |
| 14 |
|
| 15 |
func (e ChunkMissing) Error() string { |
| 16 |
return fmt.Sprintf("chunk %s missing from store", e.ID) |
| 17 |
} |
| 18 |
|
| 19 |
func (e NoSuchObject) Error() string { |
| 20 |
return fmt.Sprintf("object %s missing from store", e.location) |
| 21 |
} |
| 22 |
|
| 23 |
// ChunkInvalid means the chunk failed validation, either because the hash |
| 24 |
// of its content doesn't match its ID, or because the storage data couldn't |
| 25 |
// be converted to plain data in the first place, for example when |
| 26 |
// decryption or decompression fails. In the latter case Err holds the |
| 27 |
// conversion error. |
| 28 |
type ChunkInvalid struct { |
| 29 |
ID ChunkID |
| 30 |
Sum ChunkID |
| 31 |
Err error |
| 32 |
} |
| 33 |
|
| 34 |
func (e ChunkInvalid) Error() string { |
| 35 |
if e.Err != nil { |
| 36 |
return fmt.Sprintf("invalid chunk %s: %s", e.ID, e.Err) |
| 37 |
} |
| 38 |
return fmt.Sprintf("chunk id %s does not match its hash %s", e.ID, e.Sum) |
| 39 |
} |
| 40 |
|
| 41 |
func (e ChunkInvalid) Unwrap() error { |
| 42 |
return e.Err |
| 43 |
} |
| 44 |
|
| 45 |
// InvalidFormat is returned when an error occurred when parsing an archive file |
| 46 |
type InvalidFormat struct { |
| 47 |
Msg string |
| 48 |
} |
| 49 |
|
| 50 |
func (e InvalidFormat) Error() string { |
| 51 |
return fmt.Sprintf("invalid archive format : %s", e.Msg) |
| 52 |
} |
| 53 |
|
| 54 |
// Interrupted is returned when a user interrupted a long-running operation, for |
| 55 |
// example by pressing Ctrl+C |
| 56 |
type Interrupted struct{} |
| 57 |
|
| 58 |
func (e Interrupted) Error() string { return "interrupted" } |