@@ -108,30 +108,32 @@ func (conn *connection) Now() (time.Time, error) {
108
108
109
109
func (conn * connection ) Exec (query string , args ... any ) error {
110
110
_ , err := conn .db .ExecContext (conn .ctx , query , args ... )
111
- return impl . WrapNonNilErrorWithQuery (err , query , argFmt , args )
111
+ return wrapError (err , query , argFmt , args )
112
112
}
113
113
114
114
func (conn * connection ) Insert (table string , columValues sqldb.Values ) error {
115
- return impl .Insert (conn , table , argFmt , columValues )
115
+ return WrapKnownErrors ( impl .Insert (conn , table , argFmt , columValues ) )
116
116
}
117
117
118
118
func (conn * connection ) InsertUnique (table string , values sqldb.Values , onConflict string ) (inserted bool , err error ) {
119
- return impl .InsertUnique (conn , table , argFmt , values , onConflict )
119
+ inserted , err = impl .InsertUnique (conn , table , argFmt , values , onConflict )
120
+ return inserted , WrapKnownErrors (err )
120
121
}
121
122
122
123
func (conn * connection ) InsertReturning (table string , values sqldb.Values , returning string ) sqldb.RowScanner {
123
124
return impl .InsertReturning (conn , table , argFmt , values , returning )
124
125
}
125
126
126
127
func (conn * connection ) InsertStruct (table string , rowStruct any , ignoreColumns ... sqldb.ColumnFilter ) error {
127
- return impl .InsertStruct (conn , table , rowStruct , conn .structFieldNamer , argFmt , ignoreColumns )
128
+ return WrapKnownErrors ( impl .InsertStruct (conn , table , rowStruct , conn .structFieldNamer , argFmt , ignoreColumns ) )
128
129
}
129
130
130
131
func (conn * connection ) InsertStructs (table string , rowStructs any , ignoreColumns ... sqldb.ColumnFilter ) error {
131
- return impl .InsertStructs (conn , table , rowStructs , ignoreColumns ... )
132
+ return WrapKnownErrors ( impl .InsertStructs (conn , table , rowStructs , ignoreColumns ... ) )
132
133
}
133
134
134
135
func (conn * connection ) InsertUniqueStruct (table string , rowStruct any , onConflict string , ignoreColumns ... sqldb.ColumnFilter ) (inserted bool , err error ) {
136
+ // TODO more error wrapping
135
137
return impl .InsertUniqueStruct (conn , table , rowStruct , onConflict , conn .structFieldNamer , argFmt , ignoreColumns )
136
138
}
137
139
@@ -158,7 +160,7 @@ func (conn *connection) UpsertStruct(table string, rowStruct any, ignoreColumns
158
160
func (conn * connection ) QueryRow (query string , args ... any ) sqldb.RowScanner {
159
161
rows , err := conn .db .QueryContext (conn .ctx , query , args ... )
160
162
if err != nil {
161
- err = impl . WrapNonNilErrorWithQuery (err , query , argFmt , args )
163
+ err = wrapError (err , query , argFmt , args )
162
164
return sqldb .RowScannerWithError (err )
163
165
}
164
166
return impl .NewRowScanner (rows , conn .structFieldNamer , query , argFmt , args )
@@ -167,7 +169,7 @@ func (conn *connection) QueryRow(query string, args ...any) sqldb.RowScanner {
167
169
func (conn * connection ) QueryRows (query string , args ... any ) sqldb.RowsScanner {
168
170
rows , err := conn .db .QueryContext (conn .ctx , query , args ... )
169
171
if err != nil {
170
- err = impl . WrapNonNilErrorWithQuery (err , query , argFmt , args )
172
+ err = wrapError (err , query , argFmt , args )
171
173
return sqldb .RowsScannerWithError (err )
172
174
}
173
175
return impl .NewRowsScanner (conn .ctx , rows , conn .structFieldNamer , query , argFmt , args )
0 commit comments