1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-29 17:41:15 +03:00

Remove internal errors package that clashes with std lib.

This commit is contained in:
Vladimir Mihailenco
2016-10-09 11:38:31 +00:00
parent 639950777c
commit 2c5b239ecb
9 changed files with 34 additions and 41 deletions

View File

@ -1,4 +1,4 @@
package errors
package internal
import (
"io"
@ -12,16 +12,16 @@ type RedisError string
func (e RedisError) Error() string { return string(e) }
func IsRetryable(err error) bool {
return IsNetwork(err)
func IsRetryableError(err error) bool {
return IsNetworkError(err)
}
func IsInternal(err error) bool {
func IsInternalError(err error) bool {
_, ok := err.(RedisError)
return ok
}
func IsNetwork(err error) bool {
func IsNetworkError(err error) bool {
if err == io.EOF {
return true
}
@ -33,7 +33,7 @@ func IsBadConn(err error, allowTimeout bool) bool {
if err == nil {
return false
}
if IsInternal(err) {
if IsInternalError(err) {
return false
}
if allowTimeout {
@ -44,8 +44,8 @@ func IsBadConn(err error, allowTimeout bool) bool {
return true
}
func IsMoved(err error) (moved bool, ask bool, addr string) {
if !IsInternal(err) {
func IsMovedError(err error) (moved bool, ask bool, addr string) {
if !IsInternalError(err) {
return
}
@ -66,6 +66,6 @@ func IsMoved(err error) (moved bool, ask bool, addr string) {
return
}
func IsLoading(err error) bool {
func IsLoadingError(err error) bool {
return strings.HasPrefix(err.Error(), "LOADING")
}

View File

@ -5,7 +5,7 @@ import (
"fmt"
"strconv"
"gopkg.in/redis.v5/internal/errors"
"gopkg.in/redis.v5/internal"
)
const (
@ -18,7 +18,7 @@ const (
const defaultBufSize = 4096
var errScanNil = errors.RedisError("redis: Scan(nil)")
const errScanNil = internal.RedisError("redis: Scan(nil)")
func Scan(b []byte, val interface{}) error {
switch v := val.(type) {

View File

@ -2,17 +2,16 @@ package proto
import (
"bufio"
"errors"
"fmt"
"io"
"strconv"
ierrors "gopkg.in/redis.v5/internal/errors"
"gopkg.in/redis.v5/internal"
)
type MultiBulkParse func(*Reader, int64) (interface{}, error)
const errEmptyReply = internal.RedisError("redis: reply is empty")
var errEmptyReply = errors.New("redis: reply is empty")
type MultiBulkParse func(*Reader, int64) (interface{}, error)
type Reader struct {
src *bufio.Reader
@ -59,7 +58,7 @@ func (p *Reader) ReadLine() ([]byte, error) {
return nil, errEmptyReply
}
if isNilReply(line) {
return nil, ierrors.Nil
return nil, internal.Nil
}
return line, nil
}
@ -209,7 +208,7 @@ func (p *Reader) ReadScanReply() ([]string, uint64, error) {
func (p *Reader) parseBytesValue(line []byte) ([]byte, error) {
if isNilReply(line) {
return nil, ierrors.Nil
return nil, internal.Nil
}
replyLen, err := strconv.Atoi(string(line[1:]))
@ -245,7 +244,7 @@ func isNilReply(b []byte) bool {
}
func parseErrorValue(line []byte) error {
return ierrors.RedisError(string(line[1:]))
return internal.RedisError(string(line[1:]))
}
func parseStatusValue(line []byte) ([]byte, error) {
@ -258,7 +257,7 @@ func parseIntValue(line []byte) (int64, error) {
func parseArrayLen(line []byte) (int64, error) {
if isNilReply(line) {
return 0, ierrors.Nil
return 0, internal.Nil
}
return parseIntValue(line)
}