Skip to content

Commit 705d051

Browse files
committed
Slightly improve error messages if files fail to open or read
1 parent 7dd044b commit 705d051

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ struct ConfigFile {
1717

1818
impl Config {
1919
pub fn from_file<P: AsRef<Path>>(path: P) -> Config {
20-
let mut file = File::open(path).unwrap();
20+
let mut file = File::open(path).expect("Opening config file");
2121
let mut contents = String::new();
22-
file.read_to_string(&mut contents).unwrap();
22+
file.read_to_string(&mut contents).expect("Reading config file");
2323
let config: ConfigFile = toml::from_str(&contents).unwrap();
2424
let socket_mode = config.socket_mode.map(|m| u32::from_str_radix(&m, 8).unwrap());
2525
Config {

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ fn main() {
218218
hbse.add(Box::new(DirectorySource::new("/usr/share/better-than-basic/templates", ".hbs")));
219219

220220
if let Err(r) = hbse.reload() {
221-
panic!("{}", r);
221+
panic!("Error loading templates: {}", r);
222222
}
223223

224224
let mut router = Router::new();

src/users.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ pub enum LoginResult {
3232

3333
impl Users {
3434
pub fn from_file<P: AsRef<Path>>(path: P) -> Users {
35-
let mut file = File::open(path).unwrap();
35+
let mut file = File::open(path).expect("Opening users file");
3636
let mut contents = String::new();
37-
file.read_to_string(&mut contents).unwrap();
37+
file.read_to_string(&mut contents).expect("Reading users file");
3838
let users_table = contents.parse::<Value>().unwrap();
3939
let users = users_table.as_table()
4040
.unwrap()

0 commit comments

Comments
 (0)