Skip to content

Commit

Permalink
Add redis.Error interface and export ErrClosed
Browse files Browse the repository at this point in the history
Fixes redis#1295
Closes redis#1296
  • Loading branch information
vmihailenco committed May 21, 2020
1 parent 2960952 commit 07656a0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,24 @@ import (
"net"
"strings"

"github.com/go-redis/redis/v7/internal/pool"
"github.com/go-redis/redis/v7/internal/proto"
)

var ErrClosed = pool.ErrClosed

type Error interface {
error

// RedisError is a no-op function but
// serves to distinguish types that are Redis
// errors from ordinary errors: a type is a
// Redis error if it has a RedisError method.
RedisError()
}

var _ Error = proto.RedisError("")

func isRetryableError(err error, retryTimeout bool) bool {
switch err {
case nil, context.Canceled, context.DeadlineExceeded:
Expand Down
2 changes: 2 additions & 0 deletions internal/proto/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ type RedisError string

func (e RedisError) Error() string { return string(e) }

func (RedisError) RedisError() {}

//------------------------------------------------------------------------------

type MultiBulkParse func(*Reader, int64) (interface{}, error)
Expand Down

0 comments on commit 07656a0

Please sign in to comment.