forked from foxundermoon/WechatHelper708
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils_assert.go
More file actions
40 lines (34 loc) · 716 Bytes
/
Copy pathutils_assert.go
File metadata and controls
40 lines (34 loc) · 716 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
38
39
40
package wxxx
import (
"github.com/pkg/errors"
)
func AssertNotNil(o interface{}, msg string) {
if o != nil {
return
}
panic(errors.Errorf("assert not nil failed ! %s", msg))
}
func AssertTrue(cond bool, msg string) {
if cond {
return
}
panic(errors.Errorf("assert must be true failed ! %s", msg))
}
func AssertFalse(cond bool, msg string) {
if !cond {
return
}
panic(errors.Errorf("assert must be false failed ! %s", msg))
}
func AssertNotEmpty(str string, msg string) {
if IsNotEmptyStr(str) {
return
}
panic(errors.Errorf("assert must not empty failed ! %s", msg))
}
func AssertError(err error, msg string) {
if err == nil {
return
}
panic(errors.Wrapf(err, "%s :causedBy", msg))
}