mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
html,bzip2,sql: rename Error methods that return error to Err
There are three classes of methods/functions called Error: a) The Error method in the just introduced error interface b) Error methods that create or report errors (http.Error, etc) c) Error methods that return errors previously associated with the receiver (Tokenizer.Error, rows.Error, etc). This CL introduces the convention that methods in case (c) should be named Err. The reasoning for the change is: - The change differentiates the two kinds of APIs based on names rather than just on signature, unloading Error a bit - Err is closer to the err variable name that is so commonly used with the intent of verifying an error - Err is shorter and thus more convenient to be used often on error verifications, such as in iterators following the convention of the sql package. R=bradfitz, rsc CC=golang-dev https://golang.org/cl/5327064
This commit is contained in:
parent
39fcca60cb
commit
f2dc50b48d
10 changed files with 103 additions and 16 deletions
|
|
@ -620,7 +620,7 @@ func (s *Stmt) Close() error {
|
|||
// err = rows.Scan(&id, &name)
|
||||
// ...
|
||||
// }
|
||||
// err = rows.Error() // get any Error encountered during iteration
|
||||
// err = rows.Err() // get any error encountered during iteration
|
||||
// ...
|
||||
type Rows struct {
|
||||
db *DB
|
||||
|
|
@ -651,8 +651,8 @@ func (rs *Rows) Next() bool {
|
|||
return rs.lasterr == nil
|
||||
}
|
||||
|
||||
// Error returns the error, if any, that was encountered during iteration.
|
||||
func (rs *Rows) Error() error {
|
||||
// Err returns the error, if any, that was encountered during iteration.
|
||||
func (rs *Rows) Err() error {
|
||||
if rs.lasterr == io.EOF {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue