Skip to content

Commit 3698ecd

Browse files
author
yuyang
committed
add error handling
1 parent ee4d7ff commit 3698ecd

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

util/util.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"encoding/base64"
1010
"encoding/hex"
1111
"encoding/json"
12+
"errors"
1213
"fmt"
1314
"io"
1415
"io/ioutil"
@@ -255,6 +256,7 @@ func ScheduleContainer(d conf.Docker, c *docker.Client) (err error) {
255256

256257
// do request for caporal
257258
log.Debug(string(payload))
259+
log.Debug("requesting caporal api: ", d.Caporal.Host+"/container")
258260
req, err := http.NewRequest("PUT", d.Caporal.Host+"/container", bytes.NewBuffer(payload))
259261
authCode := base64.StdEncoding.EncodeToString(Encrypt([]byte(d.Auth.Username+":"+d.Auth.Password), "caoral-salt"))
260262
log.WithFields(log.Fields{"CAPORAL": "AUTH CODE"}).Debug(authCode)
@@ -273,6 +275,9 @@ func ScheduleContainer(d conf.Docker, c *docker.Client) (err error) {
273275
log.Debug(string(body))
274276

275277
log.Debug(res.StatusCode)
278+
if res.StatusCode != 200 {
279+
return errors.New(string(body))
280+
}
276281

277282
return
278283
}

0 commit comments

Comments
 (0)