diff --git a/errors.go b/errors.go index 648d4a3..da8ba84 100644 --- a/errors.go +++ b/errors.go @@ -420,3 +420,11 @@ func combine(e1, e2 error) error { return &multiError{errs: []error{e1, e2}} } } + +var SkipWarnings = ErrLogger( + func(ec ErrorCategory, code int, message string) error { + if ec > CE_Warning { + return errors.New(message) + } + return nil + }) diff --git a/godal_test.go b/godal_test.go index 7a60f04..5d7feda 100644 --- a/godal_test.go +++ b/godal_test.go @@ -3657,6 +3657,10 @@ func TestErrorHandling(t *testing.T) { err = testErrorAndLogging(ErrLogger(el.ErrorHandler)) assert.EqualError(t, err, "this is a failure message") assert.Equal(t, []string{"this is a warning message"}, el.msg) + + //warning message should not show up + err = testErrorAndLogging(SkipWarnings) + assert.EqualError(t, err, "this is a failure message") } type debugLogger struct {