Handle error in GetGeoLocationByName
Return error when fetching GeoLocations fails or the result is empty. This ensures that an error is properly returned and handled when either an error occurs during the API call or no locations are found for the given city name.
This commit is contained in:
parent
d0905266e1
commit
a4f19380ff
|
@ -43,7 +43,7 @@ type GeoLocation struct {
|
|||
// This method makes use of the OSM Nominatim API
|
||||
func (c *Client) GetGeoLocationByName(ci string) (GeoLocation, error) {
|
||||
ga, err := c.GetGeoLocationsByName(ci)
|
||||
if len(ga) < 1 {
|
||||
if err != nil || len(ga) < 1 {
|
||||
return GeoLocation{}, err
|
||||
}
|
||||
return ga[0], nil
|
||||
|
|
Loading…
Reference in a new issue