2
0

Use github.com/pkg/errors

This commit is contained in:
Jack Christensen
2017-06-04 21:30:03 -05:00
parent 3ea41e6972
commit 8f4178b3d3
86 changed files with 639 additions and 597 deletions
+6 -5
View File
@@ -3,7 +3,8 @@ package pgtype
import (
"database/sql/driver"
"encoding/hex"
"fmt"
"github.com/pkg/errors"
)
type Bytea struct {
@@ -28,7 +29,7 @@ func (dst *Bytea) Set(src interface{}) error {
if originalSrc, ok := underlyingBytesType(src); ok {
return dst.Set(originalSrc)
}
return fmt.Errorf("cannot convert %v to Bytea", value)
return errors.Errorf("cannot convert %v to Bytea", value)
}
return nil
@@ -63,7 +64,7 @@ func (src *Bytea) 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)
}
// DecodeText only supports the hex format. This has been the default since
@@ -75,7 +76,7 @@ func (dst *Bytea) DecodeText(ci *ConnInfo, src []byte) error {
}
if len(src) < 2 || src[0] != '\\' || src[1] != 'x' {
return fmt.Errorf("invalid hex format")
return errors.Errorf("invalid hex format")
}
buf := make([]byte, (len(src)-2)/2)
@@ -139,7 +140,7 @@ func (dst *Bytea) Scan(src interface{}) error {
return nil
}
return fmt.Errorf("cannot scan %T", src)
return errors.Errorf("cannot scan %T", src)
}
// Value implements the database/sql/driver Valuer interface.