Skip to content

Commit

Permalink
add errorlogger that skips warnings (#110)
Browse files Browse the repository at this point in the history
* add errorlogger that skips warnings

* fixup
  • Loading branch information
tbonfort authored Apr 19, 2023
1 parent 2de9714 commit 71f3ed8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
4 changes: 4 additions & 0 deletions godal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 71f3ed8

Please sign in to comment.