/
errors.go
50 lines (46 loc) · 2.17 KB
/
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
package cmd
import (
"strings"
"github.com/pkg/errors"
)
// these errors are for the purpose of being able to compare them later
var (
ErrEmptyConfig = errors.New("the configuration is completely empty (check config file)")
ErrEmailNoSMTP = errors.New("no email SMTP server")
ErrEmailNoTo = errors.New("no email to addresses")
ErrEmailNoFrom = errors.New("no email from addresses")
ErrEmailNoPass = errors.New("no email password")
ErrEmailNoPort = errors.New("no email port")
ErrEmailNoSubject = errors.New("no email subject")
ErrSlackNoWebHookURL = errors.New("no slack webhook url")
ErrNoContainers = errors.New("there were no containers found in the configuration file")
ErrExistCheckFail = errors.New("Existence check failure")
ErrExistCheckRecovered = errors.New("Existence check recovered")
ErrRunningCheckFail = errors.New("Running check failure")
ErrRunningCheckRecovered = errors.New("Running check recovered")
ErrCPUCheckFail = errors.New("CPU check failure")
ErrCPUCheckRecovered = errors.New("CPU check recovered")
ErrMemCheckFail = errors.New("Memory check failure")
ErrMemCheckRecovered = errors.New("Memory check recovered")
ErrMinPIDCheckFail = errors.New("Min PID check Failure")
ErrMinPIDCheckRecovered = errors.New("Min PID check recovered")
ErrMaxPIDCheckFail = errors.New("Max PID check Failure")
ErrMaxPIDCheckRecovered = errors.New("Max PID check recovered")
ErrUnknown = errors.New("Received an unknown error")
ErrPushoverAPIToken = errors.New("no pushover api token")
ErrPushoverUserKey = errors.New("no pushover user key")
ErrPushoverAPIURL = errors.New("no pushover api url")
)
// ErrContainsErr returns true if the error string contains the message
func ErrContainsErr(e, b error) bool {
switch {
case e == nil && b == nil:
return true // they are both nil and essentially equal
case e == nil || b == nil:
return false // one of them is nil (previous case took care of both nils)
case strings.Contains(e.Error(), b.Error()):
return true // b is within a
default:
return false
}
}