handled cfg load error

This commit is contained in:
Paul 2020-03-30 00:19:25 +02:00
parent 4c58ca76d2
commit 8bdad9cbd2
2 changed files with 11 additions and 2 deletions

View File

@ -13,10 +13,14 @@ import (
func main() {
var cfg config.Config
var cr coronafana.Coronafana
var err error
cfg.GetConfig()
err = cfg.GetConfig()
if err != nil {
log.Fatalln(err)
}
cr, err := coronafana.GetData(cfg)
cr, err = coronafana.GetData(cfg)
if err != nil {
log.Fatalln(err)
}

View File

@ -20,6 +20,11 @@ func GetData(cfg config.Config) (cr Coronafana, err error) {
log.Println("Getting JSON file ...")
if cfg.CoronaURL == "" {
err = fmt.Errorf("CoronaURL is not defined")
return
}
resp, err := client.Get(cfg.CoronaURL)
if err != nil {
return