mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-22 20:22:18 +00:00
report errors
Modify CheckErr and StopOnErrErr to report the error if there aren't any other messages.
This commit is contained in:
parent
78962a14f8
commit
73dd4f38d0
1 changed files with 12 additions and 4 deletions
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue