Skip to content

Commit

Permalink
Updating based on error
Browse files Browse the repository at this point in the history
  • Loading branch information
madflojo committed Oct 23, 2023
1 parent db3b966 commit 7408024
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions pkg/airport/parsers/csv/csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,17 @@ func (p *Parser) Parse() ([]airport.Airport, error) {
return nil, fmt.Errorf("unable to read csv data - %w", err)
}

// Iterate over the CSV records
for _, r := range rec {
// Convert the record to an Airport
a, err := RecordToAirport(r)
if err != nil {
// Skip headers and records with not enough fields
if err == ErrIsHeader || err == ErrNotEnoughFields {
continue
}
return nil, fmt.Errorf("unable to convert record to airport - %w", err)
// Convert the record to an Airport
a, err := RecordToAirport(rec)
if err != nil {
// Skip headers and records with not enough fields
if err == ErrIsHeader || err == ErrNotEnoughFields {
continue
}
// Append the Airport to the slice
airports = append(airports, a)
return nil, fmt.Errorf("unable to convert record to airport - %w", err)
}
// Append the Airport to the slice
airports = append(airports, a)
}

// Return the slice of Airports
Expand Down

0 comments on commit 7408024

Please sign in to comment.