Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/utils/log/error.go
akuma06 97b3a1d7ea Remove common package
Common is no more a thing
Use of TorrentParam instead of SearchParam now
Common structs for search are exported in utils/search/structs
Util has been renamed utils
2017-07-02 16:54:55 +02:00

27 lignes
766 o
Go

package log
import (
"fmt"
"github.com/Sirupsen/logrus"
"runtime"
)
// CheckError check error and return true if error is nil and return false if error is not nil.
func CheckError(err error) bool {
return CheckErrorWithMessage(err, "")
}
// CheckErrorWithMessage check error with message and log messages with stack. And then return true if error is nil and return false if error is not nil.
func CheckErrorWithMessage(err error, msg string, args ...interface{}) bool {
if err != nil {
var stack [4096]byte
runtime.Stack(stack[:], false)
if len(args) == 0 {
logrus.Error(msg + fmt.Sprintf("%q\n%s\n", err, stack[:]))
} else {
logrus.Error(fmt.Sprintf(msg, args...) + fmt.Sprintf("%q\n%s\n", err, stack[:]))
}
return false
}
return true
}