-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Description
In Statement's constructor try! statement makes impossible handling schema mismatch errors gracefully:
public final class Statement {
init(_ connection: Connection, _ SQL: String) {
self.connection = connection
try! check(sqlite3_prepare_v2(connection.handle, SQL, -1, &handle, nil))
}
This leads to crashes in some unexpected places such as:
do {
let sql = table
.filter(keyColumn == value)
.update(setters)
let rowsUpdated = try db.run(sql) // crash
} catch {
}I propose considering making Statement's constructor throwable and replacing try! with try. This will lead to API changes in other places (pluck and some other functions will become throw-able), but will allow recovering from errors.
Metadata
Metadata
Assignees
Labels
No labels