Skip to content

Commit

Permalink
chore: clarify variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Oct 12, 2024
1 parent b941f86 commit f6865e4
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions provider/ignore.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

type ignoreProvider struct {
ctx context.Context
str string
err string
set Config
}

Expand All @@ -30,7 +30,7 @@ func NewIgnoreFromConfig(ctx context.Context, other map[string]interface{}) (Pro

o := &ignoreProvider{
ctx: ctx,
str: cc.Error,
err: cc.Error,
set: cc.Set,
}

Expand All @@ -41,11 +41,10 @@ var _ SetIntProvider = (*ignoreProvider)(nil)

func ignoreError[T any](fun func(T) error, match string) func(T) error {
return func(val T) error {
err := fun(val)
if err != nil && strings.HasPrefix(err.Error(), match) {
err = nil
if err := fun(val); err != nil && !strings.HasPrefix(err.Error(), match) {
return err
}
return err
return nil
}
}

Expand All @@ -55,7 +54,7 @@ func (o *ignoreProvider) IntSetter(param string) (func(int64) error, error) {
return nil, err
}

return ignoreError(set, o.str), nil
return ignoreError(set, o.err), nil
}

var _ SetFloatProvider = (*ignoreProvider)(nil)
Expand All @@ -66,7 +65,7 @@ func (o *ignoreProvider) FloatSetter(param string) (func(float64) error, error)
return nil, err
}

return ignoreError(set, o.str), nil
return ignoreError(set, o.err), nil
}

var _ SetBoolProvider = (*ignoreProvider)(nil)
Expand All @@ -77,7 +76,7 @@ func (o *ignoreProvider) BoolSetter(param string) (func(bool) error, error) {
return nil, err
}

return ignoreError(set, o.str), nil
return ignoreError(set, o.err), nil
}

var _ SetBytesProvider = (*ignoreProvider)(nil)
Expand All @@ -88,5 +87,5 @@ func (o *ignoreProvider) BytesSetter(param string) (func([]byte) error, error) {
return nil, err
}

return ignoreError(set, o.str), nil
return ignoreError(set, o.err), nil
}

0 comments on commit f6865e4

Please sign in to comment.