summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/backend.go b/backend.go
index b91ee88..ff40f5b 100644
--- a/backend.go
+++ b/backend.go
@@ -14,6 +14,7 @@ type Backend struct {
fiw *textproto.FIWriter
cbr *textproto.CatBlobReader
+ err error
onErr func(error) error
}
@@ -24,11 +25,21 @@ func NewBackend(fastImport io.Writer, catBlob io.Reader, onErr func(error) error
if catBlob != nil {
ret.cbr = textproto.NewCatBlobReader(catBlob)
}
- ret.onErr = onErr
+ ret.onErr = func(err error) error {
+ ret.err = err
+ if onErr != nil {
+ ret.err = onErr(ret.err)
+ }
+ return ret.err
+ }
return ret
}
func (b *Backend) Do(cmd Cmd) error {
+ if b.err == nil {
+ return b.err
+ }
+
err := cmd.fiWriteCmd(b.fiw)
if err != nil {
return b.onErr(err)
@@ -37,6 +48,7 @@ func (b *Backend) Do(cmd Cmd) error {
if err != nil {
return b.onErr(err)
}
+
return nil
}