-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.go
39 lines (33 loc) · 1.2 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
package merger
const (
errDiffKindText = "merge of (%s) and (%s) is invalid"
errMergeUnsupportedText = "merge of (%s) and (%s) is unsupported"
errInvalidFieldsText = "field with name (%s) is invalid in both structs"
errDiffArrayTypesText = "different types (%s) and (%s) for array"
errDiffSliceTypesText = "different types (%s) and (%s) for slice"
errDiffMapKeyTypesText = "different types (%s) and (%s) for map key"
errDiffMapValueTypesText = "different types (%s) and (%s) for map value"
)
// MergeError types with value 2ⁿ
const (
ErrDiffKind = 1 << iota
ErrMergeUnsupported = 1 << iota
ErrInvalidFields = 1 << iota
ErrDiffArrayTypes = 1 << iota
ErrDiffSliceTypes = 1 << iota
ErrDiffMapKeyTypes = 1 << iota
ErrDiffMapValueTypes = 1 << iota
)
// TODO: Make a way to determine where exactly it has failed. Perhaps together with tracer
// MergeError represents an error which has occurred while merging
type MergeError struct {
errString string
errType int
}
func (e *MergeError) Error() string {
return e.errString
}
// Type returns the MergeError type which is one or multiple of Err constants by 2ⁿ
func (e *MergeError) Type() int {
return e.errType
}