Don't drop error in readStreamedJson.
Better fix than #3230 to make sure errors from addAllAndPin make it to the client. License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
Kevin Atkinson committed
Sep 29, 2016 at 17:32 UTC
6ae4edc65a5b1c379a423610aa3e99ef8307d72f
1 file changed
+3
-2
commands/http/client.go
+3
-2
@@ -180,7 +180,7 @@ func getResponse(httpRes *http.Response, req cmds.Request) (cmds.Response, error
180
// if output is coming from a channel, decode each chunk
181
outChan := make(chan interface{})
182
183
- go readStreamedJson(req, rr, outChan)
183
+ go readStreamedJson(req, rr, outChan, res)
184
185
res.SetOutput((<-chan interface{})(outChan))
186
return res, nil
@@ -233,7 +233,7 @@ func getResponse(httpRes *http.Response, req cmds.Request) (cmds.Response, error
233
234
// read json objects off of the given stream, and write the objects out to
235
// the 'out' channel
236
-func readStreamedJson(req cmds.Request, rr io.Reader, out chan<- interface{}) {
236
+func readStreamedJson(req cmds.Request, rr io.Reader, out chan<- interface{}, resp cmds.Response) {
237
defer close(out)
238
dec := json.NewDecoder(rr)
239
outputType := reflect.TypeOf(req.Command().Type)
@@ -245,6 +245,7 @@ func readStreamedJson(req cmds.Request, rr io.Reader, out chan<- interface{}) {
245
if err != nil {
246
if err != io.EOF {
247
log.Error(err)
248
+ resp.SetError(err, cmds.ErrNormal)
249
}
250
return
251
}