-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
53 lines (41 loc) · 900 Bytes
/
errors.go
File metadata and controls
53 lines (41 loc) · 900 Bytes
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
package vtypes
import (
"errors"
"fmt"
"reflect"
)
type Error struct {
child error
}
func NewError(child error) *Error {
return &Error{child}
}
func (e *Error) Error() string {
return fmt.Sprintf("vtypes: %v", e.child)
}
func (e *Error) Unwrap() error {
return e.child
}
func (e *Error) Is(err error) bool {
return reflect.TypeOf(e) == reflect.TypeOf(err)
}
type HydrateError struct {
child error
Val any
}
func NewHydrateError(child error, val any) *HydrateError {
return &HydrateError{child, val}
}
func (e *HydrateError) Error() string {
return fmt.Sprintf("hydrate (type: %T): %v", e.Val, e.child)
}
func (e *HydrateError) Unwrap() error {
return e.child
}
func (e *HydrateError) Is(err error) bool {
return reflect.TypeOf(e) == reflect.TypeOf(err)
}
var (
ErrTypeUnsupported = errors.New("type unsupported")
ErrValueUnsupported = errors.New("value unsupported")
)