transform: Return any read or write error from Apply

This commit is contained in:
Bjørn Erik Pedersen 2016-11-04 00:44:49 +01:00
parent 3a86aba517
commit 0cd0adda20

View file

@ -69,10 +69,14 @@ func (c *chain) Apply(w io.Writer, r io.Reader, p []byte) error {
b1 := bp.GetBuffer()
defer bp.PutBuffer(b1)
b1.ReadFrom(r)
if _, err := b1.ReadFrom(r); err != nil {
return err
}
if len(*c) == 0 {
b1.WriteTo(w)
if _, err := b1.WriteTo(w); err != nil {
return err
}
return nil
}
@ -97,6 +101,6 @@ func (c *chain) Apply(w io.Writer, r io.Reader, p []byte) error {
tr(fb)
}
fb.to.WriteTo(w)
return nil
_, err := fb.to.WriteTo(w)
return err
}