aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorTeddy Wing2017-06-03 22:18:18 +0200
committerTeddy Wing2017-06-03 22:18:18 +0200
commitf8821fa88888491bf49d8cd626f7a011665c6066 (patch)
treeff4b33480a1e6976eb2e91ea688896e8bb6f8724 /main.go
parentaa2f0f0bac6cc533b70265c9de60943abefa5931 (diff)
parent7f19527d1a89b44ae559861c5f33cf126c3b011c (diff)
downloadtimetasker-f8821fa88888491bf49d8cd626f7a011665c6066.tar.bz2
Merge branch 'handle-failing-responses-from-the-server' into timetasker-daily
Diffstat (limited to 'main.go')
-rw-r--r--main.go20
1 files changed, 15 insertions, 5 deletions
diff --git a/main.go b/main.go
index 3b7ace5..861dc8b 100644
--- a/main.go
+++ b/main.go
@@ -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)
+ }
}