diff --git a/commands/channelmarshaler.go b/commands/channelmarshaler.go index 826b32eab..02cc4545e 100644 --- a/commands/channelmarshaler.go +++ b/commands/channelmarshaler.go @@ -5,6 +5,7 @@ import "io" type ChannelMarshaler struct { Channel <-chan interface{} Marshaler func(interface{}) (io.Reader, error) + Res Response reader io.Reader } @@ -13,6 +14,10 @@ func (cr *ChannelMarshaler) Read(p []byte) (int, error) { if cr.reader == nil { val, more := <-cr.Channel if !more { + //check error in response + if cr.Res.Error() != nil { + return 0, cr.Res.Error() + } return 0, io.EOF } diff --git a/commands/response.go b/commands/response.go index a40c048df..80938ab4d 100644 --- a/commands/response.go +++ b/commands/response.go @@ -57,6 +57,7 @@ var marshallers = map[EncodingType]Marshaler{ return &ChannelMarshaler{ Channel: ch, Marshaler: marshalJson, + Res: res, }, nil } diff --git a/core/commands/dht.go b/core/commands/dht.go index 1f081ba91..0157b62e1 100644 --- a/core/commands/dht.go +++ b/core/commands/dht.go @@ -131,6 +131,7 @@ var queryDhtCmd = &cmds.Command{ return &cmds.ChannelMarshaler{ Channel: outChan, Marshaler: marshal, + Res: res, }, nil }, }, @@ -249,6 +250,7 @@ FindProviders will return a list of peers who are able to provide the value requ return &cmds.ChannelMarshaler{ Channel: outChan, Marshaler: marshal, + Res: res, }, nil }, }, @@ -354,6 +356,7 @@ var findPeerDhtCmd = &cmds.Command{ return &cmds.ChannelMarshaler{ Channel: outChan, Marshaler: marshal, + Res: res, }, nil }, }, @@ -461,6 +464,7 @@ GetValue will return the value stored in the dht at the given key. return &cmds.ChannelMarshaler{ Channel: outChan, Marshaler: marshal, + Res: res, }, nil }, }, @@ -571,6 +575,7 @@ PutValue will store the given key value pair in the dht. return &cmds.ChannelMarshaler{ Channel: outChan, Marshaler: marshal, + Res: res, }, nil }, }, diff --git a/core/commands/ping.go b/core/commands/ping.go index 2b4ff2dbf..c06aa8dc6 100644 --- a/core/commands/ping.go +++ b/core/commands/ping.go @@ -71,6 +71,7 @@ trip latency information. return &cmds.ChannelMarshaler{ Channel: outChan, Marshaler: marshal, + Res: res, }, nil }, }, diff --git a/core/commands/refs.go b/core/commands/refs.go index 1a015e2d8..b172d323a 100644 --- a/core/commands/refs.go +++ b/core/commands/refs.go @@ -141,6 +141,7 @@ Note: list all refs recursively with -r. return &cmds.ChannelMarshaler{ Channel: outChan, Marshaler: marshal, + Res: res, }, nil }, }, diff --git a/core/commands/repo.go b/core/commands/repo.go index 8ad0c7296..d0e010848 100644 --- a/core/commands/repo.go +++ b/core/commands/repo.go @@ -90,6 +90,7 @@ order to reclaim hard disk space. return &cmds.ChannelMarshaler{ Channel: outChan, Marshaler: marshal, + Res: res, }, nil }, }, diff --git a/core/commands/stat.go b/core/commands/stat.go index 5e222fa04..df4c459ec 100644 --- a/core/commands/stat.go +++ b/core/commands/stat.go @@ -167,6 +167,7 @@ var statBwCmd = &cmds.Command{ return &cmds.ChannelMarshaler{ Channel: outCh, Marshaler: marshal, + Res: res, }, nil }, },