Skip to content

Commit 5edae39

Browse files
committed
Throw SqlError from Statement.run()
1 parent c4d275a commit 5edae39

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

index.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,14 @@ class Statement {
228228
* Executes the SQL statement and returns an info object.
229229
*/
230230
run(...bindParameters) {
231-
if (bindParameters.length == 1 && typeof bindParameters[0] === "object") {
232-
return statementRun.call(this.stmt, bindParameters[0]);
233-
} else {
234-
return statementRun.call(this.stmt, bindParameters.flat());
231+
try {
232+
if (bindParameters.length == 1 && typeof bindParameters[0] === "object") {
233+
return statementRun.call(this.stmt, bindParameters[0]);
234+
} else {
235+
return statementRun.call(this.stmt, bindParameters.flat());
236+
}
237+
} catch (err) {
238+
throw new SqliteError(err.message, ""); // TODO: SQLite error code
235239
}
236240
}
237241

promise.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,14 @@ class Statement {
225225
* Executes the SQL statement and returns an info object.
226226
*/
227227
run(...bindParameters) {
228-
if (bindParameters.length == 1 && typeof bindParameters[0] === "object") {
229-
return statementRun.call(this.stmt, bindParameters[0]);
230-
} else {
231-
return statementRun.call(this.stmt, bindParameters.flat());
228+
try {
229+
if (bindParameters.length == 1 && typeof bindParameters[0] === "object") {
230+
return statementRun.call(this.stmt, bindParameters[0]);
231+
} else {
232+
return statementRun.call(this.stmt, bindParameters.flat());
233+
}
234+
} catch (err) {
235+
throw new SqliteError(err.message, ""); // TODO: SQLite error code
232236
}
233237
}
234238

0 commit comments

Comments
 (0)