diff options
author | Collin Guarino <collin.guarino@gmail.com> | 2016-01-30 12:11:47 -0500 |
---|---|---|
committer | Collin Guarino <collin.guarino@gmail.com> | 2016-01-30 12:11:47 -0500 |
commit | 779dcafebdca3282c5bcd8855ab006ab7328e49c (patch) | |
tree | aecbab93d60032da99b11e8d72e75377afd7bb6f | |
parent | 27b9932aa92b7cf92d782aedbfb891747e52ea43 (diff) |
Hacky json parsing in CreateUser. Will fix later.
-rw-r--r-- | bridge.go | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -10,7 +10,9 @@ import ( "io/ioutil" "runtime" "fmt" + "strings" "bytes" + "errors" ) type Bridge struct { @@ -102,20 +104,21 @@ func CreateUser(bridge *Bridge, deviceType string) (string, error) { } defer response.Body.Close() body, err := ioutil.ReadAll(response.Body) - log.Println(string(body)) - - data := []Error{} - err = json.Unmarshal(body, &data) if err != nil { trace("", err) - os.Exit(1) } - fmt.Println(data) + + result := string(body) + errFound := strings.Contains(result, "error") + noLink := strings.Contains(result, "link button not pressed") + if errFound && noLink { + return "", errors.New("Link button not pressed.") + } // TODO: decode and return // TODO: handle errors. http://www.developers.meethue.com/documentation/error-messages - return "", err + return "", nil } // Log the date, time, file location, line number, and function. |