apex / log

Structured logging package for Go.
MIT License
1.37k stars 112 forks source link

Ignore nil errors in WithError #87

Closed wesleimp closed 4 years ago

wesleimp commented 4 years ago

Closes #67

tj commented 4 years ago

Ah I think we should close that issue, there was another PR somewhere with further discussion but personally I think it's a user-error. 99% of the usage looks like:

err = json.NewDecoder(gz).Decode(&record)
if err != nil {
  log.WithError(err).Error("error decoding record")
  http.Error(w, "Error parsing record record", http.StatusBadRequest)
  return
}

I suppose it doesn't really hurt but I've never hit this, I'm not sure when you'd call it with a nil

wesleimp commented 4 years ago

@tj I totally agree, but IMHO it could work as a double check