mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
73dd4f38d0
Modify CheckErr and StopOnErrErr to report the error if there aren't any other messages.
32 lines
479 B
Go
32 lines
479 B
Go
package utils
|
|
|
|
import (
|
|
"os"
|
|
|
|
jww "github.com/spf13/jwalterweatherman"
|
|
)
|
|
|
|
func CheckErr(err error, s ...string) {
|
|
if err != nil {
|
|
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 {
|
|
if len(s) == 0 {
|
|
jww.CRITICAL.Println(err)
|
|
} else {
|
|
for _, message := range s {
|
|
jww.CRITICAL.Println(message)
|
|
}
|
|
}
|
|
os.Exit(-1)
|
|
}
|
|
}
|