From e201d20ebdaef42a4c5017ca751d0ca87bb86bf6 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Fri, 8 Jul 2022 04:01:38 -0400 Subject: [PATCH] Cleaned up error handling --- cmd/client/location.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/cmd/client/location.go b/cmd/client/location.go index 2fd4b5a..94d3853 100644 --- a/cmd/client/location.go +++ b/cmd/client/location.go @@ -2,7 +2,6 @@ package main import ( "encoding/json" - "fmt" "io/ioutil" "log" "net/http" @@ -12,11 +11,8 @@ import ( func getLocation(wg *sync.WaitGroup, cfg *config) { - errMsg := "\nSorry, couldn't get your location automatically" - res, err := http.Get("https://ipinfo.io/json") if err != nil { - fmt.Println(errMsg) log.Println(err) return } @@ -24,14 +20,12 @@ func getLocation(wg *sync.WaitGroup, cfg *config) { body, err := ioutil.ReadAll(res.Body) if err != nil { - fmt.Println(errMsg) - log.Panicln(err) + log.Println(err) } err = json.Unmarshal(body, &cfg) if err != nil { - fmt.Println(errMsg) - log.Fatalln(err) + log.Println(err) } loc := strings.Split(cfg.Location, ",")