-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
37 lines (29 loc) · 821 Bytes
/
errors.go
File metadata and controls
37 lines (29 loc) · 821 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
package envmodel
import (
"errors"
"fmt"
)
var (
// A field is marked as required, but the environment variable of that key is not defined
ErrRequiredKeyUndefined = errors.New("required key is not defined")
// The map entry is not specified in the correct format, expects "key:value"
ErrInvalidMapEntry = errors.New("invalid map entry")
ErrInvalidTarget = errors.New("target must be a struct pointer")
ErrUnsupportedType = errors.New("unsupported data type")
)
type typedError struct {
Msg string
Reason error
}
func newTypedError(reason error, format string, args ...interface{}) *typedError {
return &typedError{
Msg: fmt.Sprintf(format, args...),
Reason: reason,
}
}
func (err *typedError) Error() string {
return err.Msg
}
func (err *typedError) Unwrap() error {
return err.Reason
}