From 2e70e3fa1bf3eaaab7609f09ec69c6cca3b6e104 Mon Sep 17 00:00:00 2001 From: Ella Pietraroia Date: Wed, 22 Jan 2020 15:34:32 +1030 Subject: [PATCH] change to error handling --- filter/mog.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/filter/mog.go b/filter/mog.go index b83b039c..9519b656 100644 --- a/filter/mog.go +++ b/filter/mog.go @@ -87,7 +87,7 @@ func (m *MOGFilter) Write(f []byte) (int, error) { m.hfCount = 0 img, err := gocv.IMDecode(f, gocv.IMReadColor) if err != nil { - return 0, fmt.Errorf("image can't be decoded: %w", err) + return len(f), fmt.Errorf("image can't be decoded: %w", err) } defer img.Close() @@ -135,7 +135,7 @@ func (m *MOGFilter) Write(f []byte) (int, error) { // Don't write to destination if there is no motion. if len(contours) == 0 { - return 0, nil + return len(f), nil } // Write to destination, past 4 frames then current frame. @@ -143,7 +143,7 @@ func (m *MOGFilter) Write(f []byte) (int, error) { _, err := m.dst.Write(h) m.hold[i] = nil if err != nil { - return 0, err + return len(f), fmt.Errorf("could not write previous frames: %w", err) } } return m.dst.Write(f)