mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-14 08:18:30 +00:00
report errors
Modify CheckErr and StopOnErrErr to report the error if there aren't any other messages.
This commit is contained in:
1 parent
78962a14f8
commit
73dd4f38d0
1 file changed
+12
-4
+12
-4
@@ -8,16 +8,24 @@ import (
|
|||||||
|
|
||||||
func CheckErr(err error, s ...string) {
|
func CheckErr(err error, s ...string) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
for _, message := range s {
|
if len(s) == 0 {
|
||||||
jww.ERROR.Println(message)
|
jww.CRITICAL.Println(err)
|
||||||
|
} else {
|
||||||
|
for _, message := range s {
|
||||||
|
jww.ERROR.Println(message)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func StopOnErr(err error, s ...string) {
|
func StopOnErr(err error, s ...string) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
for _, message := range s {
|
if len(s) == 0 {
|
||||||
jww.CRITICAL.Println(message)
|
jww.CRITICAL.Println(err)
|
||||||
|
} else {
|
||||||
|
for _, message := range s {
|
||||||
|
jww.CRITICAL.Println(message)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user