@@ -29,21 +29,21 @@ pub struct SqliteStore {
29
29
30
30
impl SqliteStore {
31
31
pub ( crate ) fn new ( dest_dir : PathBuf ) -> Self {
32
- let msg =
33
- format ! ( "Failed to create database destination directory: {}" , dest_dir. display( ) ) ;
34
- fs :: create_dir_all ( dest_dir . clone ( ) ) . expect ( & msg ) ;
32
+ fs :: create_dir_all ( dest_dir . clone ( ) ) . unwrap_or_else ( |_| {
33
+ panic ! ( "Failed to create database destination directory: {}" , dest_dir. display( ) )
34
+ } ) ;
35
35
let mut db_file_path = dest_dir. clone ( ) ;
36
36
db_file_path. push ( SQLITE_DB_FILE ) ;
37
37
38
- let msg = format ! ( "Failed to open/create database file: {}" , db_file_path. display( ) ) ;
39
- let connection = Connection :: open ( db_file_path) . expect ( & msg) ;
38
+ let connection = Connection :: open ( db_file_path. clone ( ) ) . unwrap_or_else ( |_| {
39
+ panic ! ( "Failed to open/create database file: {}" , db_file_path. display( ) )
40
+ } ) ;
40
41
41
- let msg = format ! ( "Failed to set PRAGMA user_version" ) ;
42
42
connection
43
43
. pragma ( Some ( rusqlite:: DatabaseName :: Main ) , "user_version" , SCHEMA_USER_VERSION , |_| {
44
44
Ok ( ( ) )
45
45
} )
46
- . expect ( & msg ) ;
46
+ . unwrap_or_else ( |_| panic ! ( "Failed to set PRAGMA user_version" ) ) ;
47
47
48
48
let sql = format ! (
49
49
"CREATE TABLE IF NOT EXISTS {} (
@@ -53,8 +53,9 @@ impl SqliteStore {
53
53
);" ,
54
54
KV_TABLE_NAME
55
55
) ;
56
- let msg = format ! ( "Failed to create table: {}" , KV_TABLE_NAME ) ;
57
- connection. execute ( & sql, [ ] ) . expect ( & msg) ;
56
+ connection
57
+ . execute ( & sql, [ ] )
58
+ . unwrap_or_else ( |_| panic ! ( "Failed to create table: {}" , KV_TABLE_NAME ) ) ;
58
59
59
60
let connection = Arc :: new ( Mutex :: new ( connection) ) ;
60
61
Self { connection }
0 commit comments