@@ -183,27 +183,28 @@ func (c *Config) Set(option string, value interface{}) error {
183
183
dest := unsafeValueOf (fieldVal )
184
184
coercedVal , err := coerce (value , field .Type )
185
185
if err != nil {
186
- log . Fatalf ( "ERROR: failed to coerce option %s (%v) - %s" ,
186
+ return fmt . Errorf ( " failed to coerce option %s (%v) - %s" ,
187
187
option , value , err )
188
188
}
189
189
if min != "" {
190
190
coercedMinVal , _ := coerce (min , field .Type )
191
191
if valueCompare (coercedVal , coercedMinVal ) == - 1 {
192
- return errors . New ( fmt .Sprintf ("invalid %s ! %v < %v" ,
193
- option , coercedVal .Interface (), coercedMinVal .Interface ()))
192
+ return fmt .Errorf ("invalid %s ! %v < %v" ,
193
+ option , coercedVal .Interface (), coercedMinVal .Interface ())
194
194
}
195
195
}
196
196
if max != "" {
197
197
coercedMaxVal , _ := coerce (max , field .Type )
198
198
if valueCompare (coercedVal , coercedMaxVal ) == 1 {
199
- return errors . New ( fmt .Sprintf ("invalid %s ! %v > %v" ,
200
- option , coercedVal .Interface (), coercedMaxVal .Interface ()))
199
+ return fmt .Errorf ("invalid %s ! %v > %v" ,
200
+ option , coercedVal .Interface (), coercedMaxVal .Interface ())
201
201
}
202
202
}
203
203
dest .Set (coercedVal )
204
+ return nil
204
205
}
205
206
206
- return errors . New ( fmt .Sprintf ( "ERROR: invalid option %s" , option ) )
207
+ return fmt .Errorf ( " invalid option %s" , option )
207
208
}
208
209
209
210
// because Config contains private structs we can't use reflect.Value
0 commit comments