mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-20 02:17:39 +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
+8
@@ -8,17 +8,25 @@ import (
|
|||||||
|
|
||||||
func CheckErr(err error, s ...string) {
|
func CheckErr(err error, s ...string) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if len(s) == 0 {
|
||||||
|
jww.CRITICAL.Println(err)
|
||||||
|
} else {
|
||||||
for _, message := range s {
|
for _, message := range s {
|
||||||
jww.ERROR.Println(message)
|
jww.ERROR.Println(message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func StopOnErr(err error, s ...string) {
|
func StopOnErr(err error, s ...string) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if len(s) == 0 {
|
||||||
|
jww.CRITICAL.Println(err)
|
||||||
|
} else {
|
||||||
for _, message := range s {
|
for _, message := range s {
|
||||||
jww.CRITICAL.Println(message)
|
jww.CRITICAL.Println(message)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user