fix: gracefully handle nil err in Logger

This handles the case where a null error is passed into the Logger
without causing a null pointer dereference / segfault. There are
currently a couple places that invoke this function with a nil error and
were resulting in a segfault.
This commit is contained in:
Sam Dowell 2025-06-16 10:04:58 -07:00
parent 81dcf1617c
commit 00e00f019f
1 changed files with 3 additions and 1 deletions

View File

@ -57,9 +57,11 @@ func (l *Logger) Error(err error, msg string, kvList ...interface{}) {
Args map[string]interface{}
}{
Msg: msg,
Err: err.Error(),
Args: map[string]interface{}{},
}
if err != nil {
payload.Err = err.Error()
}
if len(kvList)%2 != 0 {
kvList = append(kvList, "<no-value>")
}