File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed
Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -1193,19 +1193,19 @@ NAN_METHOD(DBHandle::Open) {
11931193
11941194 int res = sqlite3_open_v2 (*filename, &self->db_ , flags, nullptr );
11951195 if (res != SQLITE_OK)
1196- return Nan::ThrowError ( sqlite3_errstr (res)) ;
1196+ goto on_err ;
11971197
11981198 res = sqlite3_extended_result_codes (self->db_ , 1 );
11991199 if (res != SQLITE_OK)
1200- return Nan::ThrowError ( sqlite3_errstr (res)) ;
1200+ goto on_err ;
12011201
12021202 // Disable dynamic loading of extensions
12031203 res = sqlite3_db_config (self->db_ ,
12041204 SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION,
12051205 0 ,
12061206 nullptr );
12071207 if (res != SQLITE_OK)
1208- return Nan::ThrowError ( sqlite3_errstr (res)) ;
1208+ goto on_err ;
12091209
12101210 // Disable language features that allow ordinary SQL to deliberately corrupt
12111211 // the database
@@ -1214,7 +1214,7 @@ NAN_METHOD(DBHandle::Open) {
12141214 1 ,
12151215 nullptr );
12161216 if (res != SQLITE_OK)
1217- return Nan::ThrowError ( sqlite3_errstr (res)) ;
1217+ goto on_err ;
12181218
12191219 if (self->authorizeReq ) {
12201220 res = sqlite3_set_authorizer (
@@ -1223,8 +1223,18 @@ NAN_METHOD(DBHandle::Open) {
12231223 self->authorizeReq
12241224 );
12251225 if (res != SQLITE_OK)
1226- return Nan::ThrowError (sqlite3_errstr (res));
1226+ goto on_err;
1227+ }
1228+
1229+ return ;
1230+
1231+ on_err:
1232+ Local<Value> err = Nan::Error (sqlite3_errstr (res));
1233+ if (self->db_ ) {
1234+ sqlite3_close_v2 (self->db_ );
1235+ self->db_ = nullptr ;
12271236 }
1237+ Nan::ThrowError (err);
12281238}
12291239
12301240NAN_METHOD (DBHandle::Query) {
You can’t perform that action at this time.
0 commit comments