liuxiulin 2 月之前
父节点
当前提交
86e1683c8d
共有 1 个文件被更改,包括 3 次插入0 次删除
  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