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