mirror of
https://github.com/MedzikUser/go-utils.git
synced 2024-08-15 03:26:56 +00:00
26 lines
459 B
Go
26 lines
459 B
Go
package common
|
|
|
|
import (
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
/*
|
|
This function checks for an error.
|
|
If the error isn't nil it return true and print error otherwise false.
|
|
|
|
err := errors.New("Test Error")
|
|
if common.CheckErr(err, "example error") {
|
|
return
|
|
}
|
|
|
|
fmt.Println("No error was found!")
|
|
*/
|
|
func CheckErr(err error, trace string) bool {
|
|
if err != nil {
|
|
Log.WithFields(logrus.Fields{
|
|
"trace": trace,
|
|
}).Error(err)
|
|
}
|
|
|
|
return err != nil
|
|
}
|