File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed
Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -11,13 +11,28 @@ pub fn read_config() -> Vec<Connection> {
1111 let home = std:: env:: var ( "HOME" ) . unwrap ( ) ;
1212
1313 // Full path to the toml config file.
14- let toml_path = PathBuf :: from ( format ! ( "{home}/.config/lantern/config.toml" ) ) ;
14+ let toml_path = PathBuf :: from ( home)
15+ . join ( ".config" )
16+ . join ( "lantern" )
17+ . join ( "config.toml" ) ;
1518
16- let mut f = std:: fs:: File :: open ( & toml_path) . unwrap ( ) ;
19+ let Ok ( mut f) = std:: fs:: File :: open ( & toml_path) else {
20+ eprintln ! (
21+ "ERROR: failed to read configuration file: {}" ,
22+ toml_path. display( )
23+ ) ;
24+ std:: process:: exit ( 1 ) ;
25+ } ;
1726
1827 let mut buf = String :: new ( ) ;
19- f. read_to_string ( & mut buf)
20- . expect ( "Failed to read contents of TOML config file." ) ;
28+
29+ if f. read_to_string ( & mut buf) . is_err ( ) {
30+ eprintln ! (
31+ "ERROR: failed to read configuration file: {}" ,
32+ toml_path. display( )
33+ ) ;
34+ std:: process:: exit ( 1 ) ;
35+ }
2136
2237 let c: ConfigFile = toml:: from_str ( & buf) . unwrap ( ) ;
2338
You can’t perform that action at this time.
0 commit comments