Merge pull request #2487 from skriss/fix-error-logging
don't return an error from log hook if value is not an error typepull/2500/head
commit
577af5a5b1
|
@ -0,0 +1 @@
|
|||
bug fix: in error location logging hook, if the item logged under the `error` key doesn't implement the `error` interface, don't return an error since this is a valid scenario
|
|
@ -60,7 +60,9 @@ func (h *ErrorLocationHook) Fire(entry *logrus.Entry) error {
|
|||
|
||||
err, ok := errObj.(error)
|
||||
if !ok {
|
||||
return errors.New("object logged as error does not satisfy error interface")
|
||||
// if the value isn't an error type, skip trying to get location info,
|
||||
// and just let it be logged as whatever it was
|
||||
return nil
|
||||
}
|
||||
|
||||
if errorLocationer, ok := err.(errorLocationer); ok {
|
||||
|
|
|
@ -47,7 +47,7 @@ func TestFire(t *testing.T) {
|
|||
name: "non-error logged in error field",
|
||||
preEntryFields: map[string]interface{}{logrus.ErrorKey: "not an error"},
|
||||
expectedEntryFields: map[string]interface{}{logrus.ErrorKey: "not an error"},
|
||||
expectedErr: true,
|
||||
expectedErr: false,
|
||||
},
|
||||
{
|
||||
name: "pkg/errors error",
|
||||
|
|
Loading…
Reference in New Issue