Skip to content

Commit 0102fdd

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 769dee4 commit 0102fdd

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
@@ -288,8 +288,10 @@ impl SqliteStoreInner {
288288
})?;
289289

290290
let sql = format!("SELECT user_version FROM pragma_user_version");
291-
let version_res: u16 =
292-
connection.query_row(&sql, [], |row| row.get(0)).expect("pragma query must succeed");
291+
let version_res: u16 = connection.query_row(&sql, [], |row| row.get(0)).map_err(|e| {
292+
let msg = format!("Failed to read PRAGMA user_version: {}", e);
293+
io::Error::new(io::ErrorKind::Other, msg)
294+
})?;
293295

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

0 commit comments

Comments
 (0)