liuxiulin 2 mesiacov pred
rodič
commit
86e1683c8d
1 zmenil súbory, kde vykonal 3 pridanie a 0 odobranie
  1. 3 0
      api.go

+ 3 - 0
api.go

@@ -122,6 +122,9 @@ func GetWeatherInfo(location, key string) (*WeatherInfoResp, error) {
 	if err != nil {
 		return nil, err
 	}
+	if len(info.Results) == 0 {
+		return nil, errors.New(fmt.Sprintf("天气查询失败:%s", location))
+	}
 	result.Location = info.Results[0].Location.Name
 	result.Text = info.Results[0].Now.Text
 	result.Code = info.Results[0].Now.Code