-
Notifications
You must be signed in to change notification settings - Fork 338
/
error.go
51 lines (42 loc) · 1.09 KB
/
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
49
50
51
// Copyright 2020 The Swarm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package file
// AbortError should be returned whenever a file operation is terminated
// before it has completed.
type AbortError struct {
err error
}
// NewAbortError creates a new AbortError instance.
func NewAbortError(err error) error {
return &AbortError{
err: err,
}
}
// Unwrap returns an underlying error.
func (e *AbortError) Unwrap() error {
return e.err
}
// Error implements standard go error interface.
func (e *AbortError) Error() string {
return e.err.Error()
}
// HashError should be returned whenever a file operation is terminated
// before it has completed.
type HashError struct {
err error
}
// NewHashError creates a new HashError instance.
func NewHashError(err error) error {
return &HashError{
err: err,
}
}
// Unwrap returns an underlying error.
func (e *HashError) Unwrap() error {
return e.err
}
// Error implements standard go error interface.
func (e *HashError) Error() string {
return e.err.Error()
}