提交 7daf8889 作者: Juan Batiz-Benet

cmds2: handle error return codes

上级 d18902df
......@@ -150,6 +150,10 @@ func (i *cmdInvocation) Run() (output io.Reader, err error) {
return nil, err
}
if err := res.Error(); err != nil {
return nil, err
}
return res.Reader()
}
......
......@@ -117,6 +117,11 @@ func (r *response) Marshal() ([]byte, error) {
}
encType := EncodingType(strings.ToLower(enc))
// Special case: if text encoding and an error, just print it out.
if encType == Text && r.Error() != nil {
return []byte(r.Error().Error()), nil
}
var marshaller Marshaller
if r.req.Command() != nil && r.req.Command().Marshallers != nil {
marshaller = r.req.Command().Marshallers[encType]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论