-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.go
52 lines (42 loc) · 885 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
package cfg
import (
"fmt"
"reflect"
"github.com/upfluence/cfg/provider"
)
type ProvidingError struct {
Err error
Key string
Field reflect.StructField
Provider provider.Provider
}
func (pe *ProvidingError) Unwrap() error { return pe.Err }
func (pe *ProvidingError) Error() string {
return fmt.Sprintf(
"cant provide value for %s.%s(%q, %q): %s",
pe.Field.Type.Name(),
pe.Field.Name,
pe.Key,
pe.Provider.StructTag(),
pe.Err.Error(),
)
}
type SettingError struct {
Err error
Value string
Key string
Field reflect.StructField
Provider provider.Provider
}
func (se *SettingError) Unwrap() error { return se.Err }
func (se *SettingError) Error() string {
return fmt.Sprintf(
"cant set value for %s.%s(%q, %q, %q): %s",
se.Field.Type.Name(),
se.Field.Name,
se.Key,
se.Provider.StructTag(),
se.Value,
se.Err.Error(),
)
}