@@ -3,7 +3,6 @@ use std::{
33 collections:: HashMap ,
44 ffi:: { c_int, c_uint, c_void, CStr , CString } ,
55 os:: raw:: c_char,
6- process:: exit,
76 slice,
87 sync:: Mutex ,
98} ;
@@ -63,20 +62,20 @@ pub unsafe extern "C" fn sqlite3_open_v2(
6362 let filename = CStr :: from_ptr ( filename) . to_str ( ) . unwrap ( ) ;
6463 if filename. contains ( ":memory" ) {
6564 eprintln ! ( "LibSqlite3_Turso Error: Memory store is not supported at runtime" ) ;
66- exit ( 1 ) ;
65+ return SQLITE_MISUSE ;
6766 }
6867
6968 let reqwest_client = reqwest:: Client :: builder ( )
7069 . user_agent ( "libsqlite3_turso/1.0.0" )
7170 . build ( )
7271 . unwrap ( ) ;
7372
74- let turso_config = get_tokio ( )
75- . block_on ( get_turso_db ( & reqwest_client, filename) )
76- . unwrap_or_else ( |err| {
77- eprintln ! ( "LibSqlite3_Turso Error: {}" , err ) ;
78- exit ( 1 ) ;
79- } ) ;
73+ // get turso config or return SQLITE_ERROR
74+ let turso_config = get_tokio ( ) . block_on ( get_turso_db ( & reqwest_client, filename) ) ;
75+ if turso_config . is_err ( ) {
76+ eprintln ! ( "LibSqlite3_Turso Error: {}" , turso_config . unwrap_err ( ) ) ;
77+ return SQLITE_ERROR ;
78+ }
8079
8180 let mock_db = Box :: into_raw ( Box :: new ( SQLite3 {
8281 client : reqwest_client,
@@ -86,7 +85,7 @@ pub unsafe extern "C" fn sqlite3_open_v2(
8685 delete_hook : Mutex :: new ( None ) ,
8786 insert_hook : Mutex :: new ( None ) ,
8887 update_hook : Mutex :: new ( None ) ,
89- turso_config : turso_config,
88+ turso_config : turso_config. unwrap ( ) ,
9089 } ) ) ;
9190
9291 * db = mock_db;
0 commit comments