-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.go
63 lines (50 loc) · 1.25 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
52
53
54
55
56
57
58
59
60
61
62
63
package trcache
import (
"errors"
"fmt"
)
var (
ErrNotFound = errors.New("not found") // key not found
ErrNotSupported = errors.New("not supported") // operation not supported
)
// CodecError represents an error from a [Codec] or a [KeyCodec].
type CodecError struct {
Err error
}
func (e CodecError) Error() string {
return e.Err.Error()
}
func (e CodecError) Unwrap() error {
return e.Err
}
// ValidationError represents an error from a [Validator].
type ValidationError struct {
Err error
}
func (e ValidationError) Error() string {
return e.Err.Error()
}
func (e ValidationError) Unwrap() error {
return e.Err
}
// InvalidValueTypeError represents an invalid value type error.
type InvalidValueTypeError struct {
Message string
}
func (e *InvalidValueTypeError) Error() string {
return e.Message
}
// OptionNotSupportedError represents that an options is not supported by the implementation.
type OptionNotSupportedError struct {
Message string
Option Option
}
func NewOptionNotSupportedError(option Option) OptionNotSupportedError {
return OptionNotSupportedError{
Message: fmt.Sprintf("option not supported: %s", option.CacheOptName()),
Option: option,
}
}
func (e OptionNotSupportedError) Error() string {
return e.Message
}