Skip to content

Commit

Permalink
Add more errors handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Yegor Myskin committed Jun 2, 2019
1 parent a5b6370 commit 35b69b2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tailor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 35b69b2

Please sign in to comment.