diff options
| author | Tim Möhlmann <muhlemmer@gmail.com> | 2020-01-10 12:06:53 +0200 |
|---|---|---|
| committer | Daniel Theophanes <kardianos@gmail.com> | 2020-03-19 16:17:59 +0000 |
| commit | f9f57c44430c3449a71533e78f25e88aa4c06a65 (patch) | |
| tree | 183308c050661610c71aeff1d00903497100cca3 /src/database/sql/sql.go | |
| parent | b3b174ffcf8ab4977dba1e9e18b91993a8c5a253 (diff) | |
| download | go-f9f57c44430c3449a71533e78f25e88aa4c06a65.tar.xz | |
database/sql: add method Err on sql.Row
The Row.Err method is intended to assist wrapping sql.DB.
Because sql.Row is a struct with private fields,
a wrapper in an existing code base cannot easily provide users
with a different implementation without large rewrites.
Adding this method allows query level errors to be handled
centrally.
Fixes #35804
Change-Id: I94e6329de89a7ee1284ce9ef76af4363d2d081f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/214317
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/database/sql/sql.go')
| -rw-r--r-- | src/database/sql/sql.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/database/sql/sql.go b/src/database/sql/sql.go index 1bf3731b00..95906b1318 100644 --- a/src/database/sql/sql.go +++ b/src/database/sql/sql.go @@ -3174,6 +3174,14 @@ func (r *Row) Scan(dest ...interface{}) error { return r.rows.Close() } +// Err provides a way for wrapping packages to check for +// query errors without calling Scan. +// Err returns the error, if any, that was encountered while running the query. +// If this error is not nil, this error will also be returned from Scan. +func (r *Row) Err() error { + return r.err +} + // A Result summarizes an executed SQL command. type Result interface { // LastInsertId returns the integer generated by the database |
