Skip to content

Commit

Permalink
Refactor error handling in decode_struct.go (#51)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kasugamirai authored Apr 19, 2024
1 parent aa6ea5d commit 4541166
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pkl/decode_struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,8 @@ func (d *decoder) decodePair(typ reflect.Type) (*reflect.Value, error) {
}
secondField, exists := typ.FieldByName("Second")
if !exists {
if !exists {
return nil, &InternalError{
err: errors.New("unable to find field `Second` on pkl.Pair"),
}
return nil, &InternalError{
err: errors.New("unable to find field `Second` on pkl.Pair"),
}
}
second, err := d.Decode(secondField.Type)
Expand Down

0 comments on commit 4541166

Please sign in to comment.