-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.go
80 lines (67 loc) · 1.82 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package config
// Imports needed list
import (
"fmt"
)
// KeyNotExistErr Error
type KeyNotExistErr struct {
Key interface{}
Category interface{}
Err error
}
// Error method - satisfying error interface
func (err *KeyNotExistErr) Error() string {
return fmt.Sprintf("The key: '%v' does not exist in %v | %v", err.Key, err.Category, err.Err)
}
// NewKeyNotExistErr - return a new instance of KeyNotExistErr
func NewKeyNotExistErr(key, category string, err error) error {
return &KeyNotExistErr{
Key: key,
Category: category,
Err: err,
}
}
// CategoryNotExistErr Error
type CategoryNotExistErr struct {
Key interface{}
Err error
}
// Error method - satisfying error interface
func (err *CategoryNotExistErr) Error() string {
return fmt.Sprintf("The config file '%v' does not exist | %v", err.Key, err.Err)
}
// NewCategoryNotExistErr - return a new instance of CategoryNotExistErr
func NewCategoryNotExistErr(key string, err error) error {
return &CategoryNotExistErr{
Key: key,
Err: err,
}
}
// RemoteLoadErr Error
type RemoteLoadErr struct {
Name interface{}
Err error
}
// Error method - satisfying error interface
func (err *RemoteLoadErr) Error() string {
return fmt.Sprintf("Cannot load remote config: %v | %v", err.Name, err.Err)
}
// NewRemoteLoadErr - return a new instance of RemoteLoadErr
func NewRemoteLoadErr(name interface{}, err error) error {
return &RemoteLoadErr{
Name: name,
Err: err,
}
}
// RemoteResponseErr Error
type RemoteResponseErr struct {
Err error
}
// Error method - satisfying error interface
func (err *RemoteResponseErr) Error() string {
return fmt.Sprintf("Cannot get response from remote | %v", err.Err)
}
// NewRemoteResponseErr - return a new instance of RemoteResponseErr
func NewRemoteResponseErr(err error) error {
return &RemoteResponseErr{Err: err}
}