Communicate upstream errors to client
This commit is contained in:
parent
cc49c07b1b
commit
212462be3d
|
@ -20,10 +20,15 @@ func server() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func returnWeather(c *gin.Context) {
|
func returnWeather(c *gin.Context) {
|
||||||
jsonData := getJSON()
|
jsonData, err := getJSON()
|
||||||
|
if err != nil {
|
||||||
|
e := fmt.Sprint(err)
|
||||||
|
c.String(http.StatusInternalServerError, e)
|
||||||
|
return
|
||||||
|
}
|
||||||
textBytes := []byte(jsonData)
|
textBytes := []byte(jsonData)
|
||||||
aemetRequest := root{}
|
aemetRequest := root{}
|
||||||
err := json.Unmarshal(textBytes, &aemetRequest)
|
err = json.Unmarshal(textBytes, &aemetRequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error occurred unmarshalling data: %v\n", err)
|
log.Fatalf("Error occurred unmarshalling data: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue