Skip to content

Commit 1905ad6

Browse files
committed
Propagate sqlite schema version read errors
Replace the user_version query unwrap with normal io::Error propagation so database initialization failures are reported cleanly instead of panicking. Co-Authored-By: HAL 9000
1 parent 7576a9b commit 1905ad6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/io/sqlite_store/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,10 @@ impl SqliteStoreInner {
289289
})?;
290290

291291
let sql = format!("SELECT user_version FROM pragma_user_version");
292-
#[allow(clippy::unwrap_used)]
293-
let version_res: u16 = connection.query_row(&sql, [], |row| row.get(0)).unwrap();
292+
let version_res: u16 = connection.query_row(&sql, [], |row| row.get(0)).map_err(|e| {
293+
let msg = format!("Failed to read PRAGMA user_version: {}", e);
294+
io::Error::new(io::ErrorKind::Other, msg)
295+
})?;
294296

295297
if version_res == 0 {
296298
// New database, set our SCHEMA_USER_VERSION and continue

0 commit comments

Comments
 (0)