File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 18
18
use CodeIgniter \Database \Exceptions \DatabaseException ;
19
19
use CodeIgniter \Events \Events ;
20
20
use ErrorException ;
21
+ use Exception ;
21
22
22
23
/**
23
24
* @template TConnection
@@ -125,8 +126,13 @@ public function execute(...$data)
125
126
try {
126
127
$ exception = null ;
127
128
$ result = $ this ->_execute ($ data );
129
+ } catch (BadMethodCallException $ exception ) {
130
+ throw $ exception ;
128
131
} catch (ArgumentCountError |ErrorException $ exception ) {
129
132
$ result = false ;
133
+ } catch (Exception $ exception ) {
134
+ // SQLite3 throws `Exception`.
135
+ $ result = false ;
130
136
}
131
137
132
138
// Update our query object
Original file line number Diff line number Diff line change 15
15
16
16
use CodeIgniter \Database \BaseConnection ;
17
17
use CodeIgniter \Database \Exceptions \DatabaseException ;
18
- use ErrorException ;
19
18
use Exception ;
20
19
use SQLite3 ;
21
20
use SQLite3Result ;
@@ -87,9 +86,13 @@ public function connect(bool $persistent = false)
87
86
$ this ->database = WRITEPATH . $ this ->database ;
88
87
}
89
88
90
- return (! $ this ->password )
89
+ $ sqlite = (! $ this ->password )
91
90
? new SQLite3 ($ this ->database )
92
91
: new SQLite3 ($ this ->database , SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE , $ this ->password );
92
+
93
+ $ sqlite ->enableExceptions (true );
94
+
95
+ return $ sqlite ;
93
96
} catch (Exception $ e ) {
94
97
throw new DatabaseException ('SQLite3 error: ' . $ e ->getMessage ());
95
98
}
@@ -146,7 +149,7 @@ protected function execute(string $sql)
146
149
return $ this ->isWriteType ($ sql )
147
150
? $ this ->connID ->exec ($ sql )
148
151
: $ this ->connID ->query ($ sql );
149
- } catch (ErrorException $ e ) {
152
+ } catch (Exception $ e ) {
150
153
log_message ('error ' , (string ) $ e );
151
154
152
155
if ($ this ->DBDebug ) {
You can’t perform that action at this time.
0 commit comments