diff options
author | Teddy Wing | 2017-06-03 22:18:18 +0200 |
---|---|---|
committer | Teddy Wing | 2017-06-03 22:18:18 +0200 |
commit | f8821fa88888491bf49d8cd626f7a011665c6066 (patch) | |
tree | ff4b33480a1e6976eb2e91ea688896e8bb6f8724 /main.go | |
parent | aa2f0f0bac6cc533b70265c9de60943abefa5931 (diff) | |
parent | 7f19527d1a89b44ae559861c5f33cf126c3b011c (diff) | |
download | timetasker-f8821fa88888491bf49d8cd626f7a011665c6066.tar.bz2 |
Merge branch 'handle-failing-responses-from-the-server' into timetasker-daily
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -3,8 +3,8 @@ package main import ( "fmt" "io/ioutil" - "log" "os" + "strings" "time" "github.com/teddywing/timetasker/timetask" @@ -97,17 +97,27 @@ func main() { password, ) kingpin.FatalIfError(err, "login request failed") - log.Printf("%+v\n", resp) defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) - log.Println(string(body)) + if strings.Contains( + string(body), + "The username and password don't appear to be valid.", + ) { + kingpin.Errorf("TimeTask authentication failed") + os.Exit(1) + } resp, err = timetask.SubmitTimeEntry(*client, time_entry) kingpin.FatalIfError(err, "time entry submission request failed") - log.Printf("%+v\n", resp) defer resp.Body.Close() body, err = ioutil.ReadAll(resp.Body) - log.Println(string(body)) + if strings.Contains( + string(body), + "No time entries were created.", + ) { + kingpin.Errorf("time entry creation failed") + os.Exit(1) + } } |