From 35b69b288e2766260e9b811a2f58b46465c2f01b Mon Sep 17 00:00:00 2001 From: Yegor Myskin Date: Sun, 2 Jun 2019 03:42:08 +0300 Subject: [PATCH] Add more errors handling --- tailor.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tailor.go b/tailor.go index c107e4a..daeebc4 100644 --- a/tailor.go +++ b/tailor.go @@ -149,7 +149,11 @@ func (t *Tailor) readLoop(ctx context.Context) (chan Line, chan error) { line = part break } + } else { + errs <- errors.Wrap(err, "error reading line") + return } + line = append(line, part...) if len(line) == 0 && err == io.EOF { @@ -164,10 +168,10 @@ func (t *Tailor) readLoop(ctx context.Context) (chan Line, chan error) { } // check that logrotate swapped the file - if err == io.EOF && len(line) == 0 { + if len(line) == 0 && err == io.EOF { isSameFile, err := t.isFileStillTheSame() if err != nil { - errs <- err + errs <- errors.Wrap(err, "error checking that file is the same") return } @@ -208,7 +212,7 @@ func (t *Tailor) readLoop(ctx context.Context) (chan Line, chan error) { continue } if err != nil && err != io.EOF { - errs <- errors.Wrapf(err, "error reading Line") + errs <- errors.Wrap(err, "error reading line") return }