Skip to content

Commit c7866af

Browse files
authored
Don't return an error when there's no error in the ConfigService (#6)
The ConfigService unconditionally returns an error for some methods: Set, SetAll, Del. This is confusing for the caller, when there's no error, it should just return nil.
1 parent 873b1f4 commit c7866af

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

config.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ func (f *ConfigService) SetAll(ctx context.Context, config interface{}) error {
6969
}
7070
req.Header.Set("content-type", "application/json")
7171
_, err = f.client.Do(req, nil) // nolint:bodyclose
72-
return fmt.Errorf("%w", err)
72+
if err != nil {
73+
return fmt.Errorf("%w", err)
74+
}
75+
return nil
7376
}
7477

7578
// Set updates given config key's value.
@@ -93,7 +96,11 @@ func (f *ConfigService) Set(ctx context.Context, key string, value interface{})
9396
}
9497
req.Header.Set("content-type", "application/json")
9598
_, err = f.client.Do(req, nil) // nolint:bodyclose
96-
return fmt.Errorf("%w", err)
99+
if err != nil {
100+
return fmt.Errorf("%w", err)
101+
}
102+
return nil
103+
97104
}
98105

99106
// Del destroys config item via given key.
@@ -103,5 +110,8 @@ func (f *ConfigService) Del(ctx context.Context, key string) error {
103110
return fmt.Errorf("%w", err)
104111
}
105112
_, err = f.client.Do(req, nil) // nolint:bodyclose
106-
return fmt.Errorf("%w", err)
113+
if err != nil {
114+
return fmt.Errorf("%w", err)
115+
}
116+
return nil
107117
}

0 commit comments

Comments
 (0)