Skip to content

Commit 4541166

Browse files
authored
Refactor error handling in decode_struct.go (#51)
This commit simplifies the error handling process within the decode_struct.go file. It removes an unnecessary nested conditional check around the existence of the 'Second' field, streamlining the code for better readability and efficiency.
1 parent aa6ea5d commit 4541166

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

pkl/decode_struct.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,8 @@ func (d *decoder) decodePair(typ reflect.Type) (*reflect.Value, error) {
228228
}
229229
secondField, exists := typ.FieldByName("Second")
230230
if !exists {
231-
if !exists {
232-
return nil, &InternalError{
233-
err: errors.New("unable to find field `Second` on pkl.Pair"),
234-
}
231+
return nil, &InternalError{
232+
err: errors.New("unable to find field `Second` on pkl.Pair"),
235233
}
236234
}
237235
second, err := d.Decode(secondField.Type)

0 commit comments

Comments
 (0)