Use github.com/pkg/errors
This commit is contained in:
+8
-7
@@ -2,8 +2,9 @@ package pgtype
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Network address family is dependent on server socket.h value for AF_INET.
|
||||
@@ -45,7 +46,7 @@ func (dst *Inet) Set(src interface{}) error {
|
||||
if originalSrc, ok := underlyingPtrType(src); ok {
|
||||
return dst.Set(originalSrc)
|
||||
}
|
||||
return fmt.Errorf("cannot convert %v to Inet", value)
|
||||
return errors.Errorf("cannot convert %v to Inet", value)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -76,7 +77,7 @@ func (src *Inet) AssignTo(dst interface{}) error {
|
||||
return nil
|
||||
case *net.IP:
|
||||
if oneCount, bitCount := src.IPNet.Mask.Size(); oneCount != bitCount {
|
||||
return fmt.Errorf("cannot assign %v to %T", src, dst)
|
||||
return errors.Errorf("cannot assign %v to %T", src, dst)
|
||||
}
|
||||
*v = make(net.IP, len(src.IPNet.IP))
|
||||
copy(*v, src.IPNet.IP)
|
||||
@@ -90,7 +91,7 @@ func (src *Inet) AssignTo(dst interface{}) error {
|
||||
return NullAssignTo(dst)
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot decode %v into %T", src, dst)
|
||||
return errors.Errorf("cannot decode %v into %T", src, dst)
|
||||
}
|
||||
|
||||
func (dst *Inet) DecodeText(ci *ConnInfo, src []byte) error {
|
||||
@@ -128,7 +129,7 @@ func (dst *Inet) DecodeBinary(ci *ConnInfo, src []byte) error {
|
||||
}
|
||||
|
||||
if len(src) != 8 && len(src) != 20 {
|
||||
return fmt.Errorf("Received an invalid size for a inet: %d", len(src))
|
||||
return errors.Errorf("Received an invalid size for a inet: %d", len(src))
|
||||
}
|
||||
|
||||
// ignore family
|
||||
@@ -173,7 +174,7 @@ func (src *Inet) EncodeBinary(ci *ConnInfo, buf []byte) ([]byte, error) {
|
||||
case net.IPv6len:
|
||||
family = defaultAFInet6
|
||||
default:
|
||||
return nil, fmt.Errorf("Unexpected IP length: %v", len(src.IPNet.IP))
|
||||
return nil, errors.Errorf("Unexpected IP length: %v", len(src.IPNet.IP))
|
||||
}
|
||||
|
||||
buf = append(buf, family)
|
||||
@@ -205,7 +206,7 @@ func (dst *Inet) Scan(src interface{}) error {
|
||||
return dst.DecodeText(nil, srcCopy)
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot scan %T", src)
|
||||
return errors.Errorf("cannot scan %T", src)
|
||||
}
|
||||
|
||||
// Value implements the database/sql/driver Valuer interface.
|
||||
|
||||
Reference in New Issue
Block a user