@@ -130,6 +130,9 @@ func (db *Database) SetEventHandler(handler ErrorHandler) {
130
130
// Exec executes an SQL statement on a new connection
131
131
func (db * Database ) Exec (ctx context.Context , sql string , args ... interface {}) (int64 , error ) {
132
132
ct , err := db .pool .Exec (ctx , sql , args ... )
133
+ if err != nil {
134
+ err = newError (err , "unable to execute command" )
135
+ }
133
136
return ct .RowsAffected (), db .processError (err )
134
137
}
135
138
@@ -145,7 +148,7 @@ func (db *Database) Exec(ctx context.Context, sql string, args ...interface{}) (
145
148
// 3. To avoid overflows on high uint64 values, store them in NUMERIC(24,0) fields.
146
149
// 4. For time-only fields, date is set to Jan 1, 2000 by PGX in time.Time variables.
147
150
func (db * Database ) QueryRow (ctx context.Context , sql string , args ... interface {}) Row {
148
- return rowGetter {
151
+ return & rowGetter {
149
152
db : db ,
150
153
row : db .pool .QueryRow (ctx , sql , args ... ),
151
154
}
@@ -154,7 +157,10 @@ func (db *Database) QueryRow(ctx context.Context, sql string, args ...interface{
154
157
// QueryRows executes a SQL query on a new connection
155
158
func (db * Database ) QueryRows (ctx context.Context , sql string , args ... interface {}) Rows {
156
159
rows , err := db .pool .Query (ctx , sql , args ... )
157
- return rowsGetter {
160
+ if err != nil {
161
+ err = newError (err , "unable to scan row" )
162
+ }
163
+ return & rowsGetter {
158
164
db : db ,
159
165
ctx : ctx ,
160
166
rows : rows ,
@@ -168,11 +174,14 @@ func (db *Database) Copy(ctx context.Context, tableName string, columnNames []st
168
174
ctx ,
169
175
pgx.Identifier {tableName },
170
176
columnNames ,
171
- copyWithCallback {
177
+ & copyWithCallback {
172
178
ctx : ctx ,
173
179
callback : callback ,
174
180
},
175
181
)
182
+ if err != nil {
183
+ err = newError (err , "unable to execute command" )
184
+ }
176
185
177
186
// Done
178
187
return n , db .processError (err )
0 commit comments