Skip to content

Commit

Permalink
check for nil error in LogError()
Browse files Browse the repository at this point in the history
  • Loading branch information
patricksanders committed Feb 7, 2022
1 parent 50ae0fa commit 3957dc5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/logging/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,10 @@ func RegisterLogger(l *logrus.Entry) {

// LogError is a helper function that allows for errors to be logged easily
func LogError(err error, message string) {
Log.WithError(err).Errorln(message)
if err != nil {
Log.WithError(err).Errorln(message)
} else {
Log.Warnln("LogError() called with nil error")
Log.Errorln(message)
}
}

0 comments on commit 3957dc5

Please sign in to comment.