@@ -40,6 +40,7 @@ const {
4040 databaseOpen,
4141 databaseOpenWithSync,
4242 databaseInTransaction,
43+ databaseInterrupt,
4344 databaseClose,
4445 databaseSyncAsync,
4546 databaseSyncUntilAsync,
@@ -246,6 +247,13 @@ class Database {
246247 } ) ;
247248 }
248249
250+ /**
251+ * Interrupts the database connection.
252+ */
253+ interrupt ( ) {
254+ databaseInterrupt . call ( this . db ) ;
255+ }
256+
249257 /**
250258 * Closes the database connection.
251259 */
@@ -309,10 +317,14 @@ class Statement {
309317 * @param bindParameters - The bind parameters for executing the statement.
310318 */
311319 get ( ...bindParameters ) {
312- if ( bindParameters . length == 1 && typeof bindParameters [ 0 ] === "object" ) {
313- return statementGet . call ( this . stmt , bindParameters [ 0 ] ) ;
314- } else {
315- return statementGet . call ( this . stmt , bindParameters . flat ( ) ) ;
320+ try {
321+ if ( bindParameters . length == 1 && typeof bindParameters [ 0 ] === "object" ) {
322+ return statementGet . call ( this . stmt , bindParameters [ 0 ] ) ;
323+ } else {
324+ return statementGet . call ( this . stmt , bindParameters . flat ( ) ) ;
325+ }
326+ } catch ( e ) {
327+ throw convertError ( e ) ;
316328 }
317329 }
318330
@@ -332,18 +344,22 @@ class Statement {
332344 nextRows : Array ( 100 ) ,
333345 nextRowIndex : 100 ,
334346 next ( ) {
335- if ( this . nextRowIndex === 100 ) {
336- this . nextRows . fill ( null ) ;
337- rowsNext . call ( rows , this . nextRows ) ;
338- this . nextRowIndex = 0 ;
339- }
340- const row = this . nextRows [ this . nextRowIndex ] ;
341- this . nextRows [ this . nextRowIndex ] = null ;
342- if ( ! row ) {
343- return { done : true } ;
347+ try {
348+ if ( this . nextRowIndex === 100 ) {
349+ this . nextRows . fill ( null ) ;
350+ rowsNext . call ( rows , this . nextRows ) ;
351+ this . nextRowIndex = 0 ;
352+ }
353+ const row = this . nextRows [ this . nextRowIndex ] ;
354+ this . nextRows [ this . nextRowIndex ] = null ;
355+ if ( ! row ) {
356+ return { done : true } ;
357+ }
358+ this . nextRowIndex ++ ;
359+ return { value : row , done : false } ;
360+ } catch ( e ) {
361+ throw convertError ( e ) ;
344362 }
345- this . nextRowIndex ++ ;
346- return { value : row , done : false } ;
347363 } ,
348364 [ Symbol . iterator ] ( ) {
349365 return this ;
@@ -358,12 +374,16 @@ class Statement {
358374 * @param bindParameters - The bind parameters for executing the statement.
359375 */
360376 async all ( ...bindParameters ) {
361- const result = [ ] ;
362- const it = await this . iterate ( ...bindParameters ) ;
363- for ( const row of it ) {
364- result . push ( row ) ;
377+ try {
378+ const result = [ ] ;
379+ const it = await this . iterate ( ...bindParameters ) ;
380+ for ( const row of it ) {
381+ result . push ( row ) ;
382+ }
383+ return result ;
384+ } catch ( e ) {
385+ throw convertError ( e ) ;
365386 }
366- return result ;
367387 }
368388
369389 /**
0 commit comments