-
Notifications
You must be signed in to change notification settings - Fork 1
/
errors.go
56 lines (41 loc) · 918 Bytes
/
errors.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
package dedupe
import (
"errors"
"fmt"
)
type InvalidRecordError struct {
id string
error error
}
func InvalidRecord(id string, error error) *InvalidRecordError {
e := &InvalidRecordError{
id: id,
error: error,
}
return e
}
func IsInvalidRecordError(e error) bool {
var invalid *InvalidRecordError
return errors.As(e, &invalid)
}
func (e *InvalidRecordError) Error() string {
return fmt.Sprintf("%s is an invalid record, %v", e.id, e.error)
}
func (e *InvalidRecordError) String() string {
return e.Error()
}
type NotImplementedError struct{}
func NotImplemented() *NotImplementedError {
e := &NotImplementedError{}
return e
}
func IsNotImplementedError(e error) bool {
var invalid *NotImplementedError
return errors.As(e, &invalid)
}
func (e *NotImplementedError) Error() string {
return "Not implemented"
}
func (e *NotImplementedError) String() string {
return e.Error()
}