Consolidate lib/rac's error messages

This commit is contained in:
Nigel Tao committed 2019-08-08 16:05:58 +10:00
1 parent 46a14c25f5
commit 685cf410bd
5 files changed
+59 -50

No files matched your search

+2 -12
View File
@@ -15,20 +15,10 @@
package rac
import (
"errors"
"fmt"
"io"
)
var (
errInvalidChunk = errors.New("rac: invalid chunk")
errInvalidChunkTooLarge = errors.New("rac: invalid chunk (too large)")
errInvalidChunkTruncated = errors.New("rac: invalid chunk (truncated)")
errInvalidReadSeeker = errors.New("rac: invalid ReadSeeker")
errInternalInconsistentPosition = errors.New("rac: internal error: inconsistent position")
)
// ReaderContext contains the decoded Codec-specific metadata (non-primary
// data) associated with a RAC chunk.
type ReaderContext struct {
@@ -377,12 +367,12 @@ func (r *Reader) Seek(offset int64, whence int) (int64, error) {
}
pos = end + offset
default:
return 0, errors.New("rac.Reader.Seek: invalid whence")
return 0, errSeekToInvalidWhence
}
if r.pos != pos {
if pos < 0 {
r.err = errors.New("rac.Reader.Seek: negative position")
r.err = errSeekToNegativePosition
return 0, r.err
}
if err := r.parser.SeekToChunkContaining(pos); err != nil {