Skip to content

Commit 21a1b07

Browse files
committedJul 1, 2013
rows: clean up error handling
1 parent ff69942 commit 21a1b07

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed
 

‎errors.go

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
)
1818

1919
var (
20+
errInvalidConn = errors.New("Invalid Connection")
2021
errMalformPkt = errors.New("Malformed Packet")
2122
errNoTLS = errors.New("TLS encryption requested but server does not support TLS")
2223
errOldPassword = errors.New("It seems like you are using old_passwords, which is unsupported. See https://github.com/go-sql-driver/mysql/wiki/old_passwords")

‎rows.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ package mysql
1111

1212
import (
1313
"database/sql/driver"
14-
"errors"
1514
"io"
1615
)
1716

@@ -44,7 +43,7 @@ func (rows *mysqlRows) Close() (err error) {
4443
// Remove unread packets from stream
4544
if !rows.eof {
4645
if rows.mc == nil {
47-
return errors.New("Invalid Connection")
46+
return errInvalidConn
4847
}
4948

5049
err = rows.mc.readUntilEOF()
@@ -53,17 +52,16 @@ func (rows *mysqlRows) Close() (err error) {
5352
return
5453
}
5554

56-
func (rows *mysqlRows) Next(dest []driver.Value) error {
55+
func (rows *mysqlRows) Next(dest []driver.Value) (err error) {
5756
if rows.eof {
5857
return io.EOF
5958
}
6059

6160
if rows.mc == nil {
62-
return errors.New("Invalid Connection")
61+
return errInvalidConn
6362
}
6463

6564
// Fetch next row from stream
66-
var err error
6765
if rows.binary {
6866
err = rows.readBinaryRow(dest)
6967
} else {

0 commit comments

Comments
 (0)
Please sign in to comment.