fixed handling of errors from lex methods

This commit is contained in:
Saxon 2020-01-22 13:45:01 +10:30
parent 78484b5f5b
commit 9b8667e56c
2 changed files with 5 additions and 6 deletions

View File

@ -28,7 +28,6 @@ LICENSE
package h265 package h265
import ( import (
"errors"
"io" "io"
"testing" "testing"
) )
@ -248,8 +247,8 @@ func TestLex(t *testing.T) {
r := &rtpReader{packets: test.packets} r := &rtpReader{packets: test.packets}
d := &destination{} d := &destination{}
err := NewLexer(test.donl).Lex(d, r, 0) err := NewLexer(test.donl).Lex(d, r, 0)
switch { switch err {
case err == nil || errors.Is(err, io.EOF): // Do nothing case nil, io.EOF: // Do nothing
default: default:
t.Fatalf("error lexing: %v\n", err) t.Fatalf("error lexing: %v\n", err)
} }

View File

@ -849,9 +849,9 @@ func (r *Revid) Update(vars map[string]string) error {
func (r *Revid) processFrom(read io.Reader, delay time.Duration) { func (r *Revid) processFrom(read io.Reader, delay time.Duration) {
err := r.lexTo(r.filters[0], read, delay) err := r.lexTo(r.filters[0], read, delay)
r.cfg.Logger.Log(logger.Debug, pkg+"finished lexing") r.cfg.Logger.Log(logger.Debug, pkg+"finished lexing")
switch { switch err {
case err == nil: // Do nothing. case nil: // Do nothing.
case errors.Is(err, io.EOF): // TODO: handle this depending on loop mode. case io.EOF: // TODO: handle this depending on loop mode.
default: default:
r.err <- err r.err <- err
} }