mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-06 13:26:26 +00:00
don't return an error from log hook if value is not an error type
Signed-off-by: Steve Kriss <krisss@vmware.com>
This commit is contained in:
1
changelogs/unreleased/2487-skriss
Normal file
1
changelogs/unreleased/2487-skriss
Normal file
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user