zeroshade commented on code in PR #730:
URL: https://github.com/apache/arrow-adbc/pull/730#discussion_r1219937953


##########
go/adbc/pkg/_tmpl/driver.go.tmpl:
##########
@@ -237,23 +297,33 @@ func {{.Prefix}}ConnectionNew(cnxn 
*C.struct_AdbcConnection, err *C.struct_AdbcE
 }
 
 //export {{.Prefix}}ConnectionSetOption
-func {{.Prefix}}ConnectionSetOption(cnxn *C.struct_AdbcConnection, key, val 
*C.cchar_t, err *C.struct_AdbcError) C.AdbcStatusCode {
+func {{.Prefix}}ConnectionSetOption(cnxn *C.struct_AdbcConnection, key, val 
*C.cchar_t, err *C.struct_AdbcError) (code C.AdbcStatusCode) {
        if !checkConnAlloc(cnxn, err, "AdbcConnectionSetOption") {
                return C.ADBC_STATUS_INVALID_STATE
        }
+       defer func() {
+               if e := recover(); e != nil {
+                       code = poison(err, "AdbcConnectionSetOption", e)
+               }
+       }()

Review Comment:
   should likely be before the `if !checkConnAlloc` in case anything somehow 
panics in there.



##########
go/adbc/pkg/_tmpl/driver.go.tmpl:
##########
@@ -237,23 +297,33 @@ func {{.Prefix}}ConnectionNew(cnxn 
*C.struct_AdbcConnection, err *C.struct_AdbcE
 }
 
 //export {{.Prefix}}ConnectionSetOption
-func {{.Prefix}}ConnectionSetOption(cnxn *C.struct_AdbcConnection, key, val 
*C.cchar_t, err *C.struct_AdbcError) C.AdbcStatusCode {
+func {{.Prefix}}ConnectionSetOption(cnxn *C.struct_AdbcConnection, key, val 
*C.cchar_t, err *C.struct_AdbcError) (code C.AdbcStatusCode) {
        if !checkConnAlloc(cnxn, err, "AdbcConnectionSetOption") {
                return C.ADBC_STATUS_INVALID_STATE
        }
+       defer func() {
+               if e := recover(); e != nil {
+                       code = poison(err, "AdbcConnectionSetOption", e)
+               }
+       }()
        conn := getFromHandle[cConn](cnxn.private_data)
 
-       code := errToAdbcErr(err, 
conn.cnxn.(adbc.PostInitOptions).SetOption(C.GoString(key), C.GoString(val)))
-       return C.AdbcStatusCode(code)
+       rawCode := errToAdbcErr(err, 
conn.cnxn.(adbc.PostInitOptions).SetOption(C.GoString(key), C.GoString(val)))
+       return C.AdbcStatusCode(rawCode)
 }
 
 //export {{.Prefix}}ConnectionInit
-func {{.Prefix}}ConnectionInit(cnxn *C.struct_AdbcConnection, db 
*C.struct_AdbcDatabase, err *C.struct_AdbcError) C.AdbcStatusCode {
+func {{.Prefix}}ConnectionInit(cnxn *C.struct_AdbcConnection, db 
*C.struct_AdbcDatabase, err *C.struct_AdbcError) (code C.AdbcStatusCode) {
        if !checkConnAlloc(cnxn, err, "AdbcConnectionInit") {
                return C.ADBC_STATUS_INVALID_STATE
        }
-
+       defer func() {
+               if e := recover(); e != nil {
+                       code = poison(err, "AdbcConnectionInit", e)
+               }
+       }()

Review Comment:
   same



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to