Skip to content

Commit e46a125

Browse files
committed
Improve IO error messages slightly
1 parent b617309 commit e46a125

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/main.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ fn format_pretty(data: &Vec<Vec<String>>) -> String {
8585
].join("\n")
8686
}
8787

88-
fn main() -> Result<()> {
88+
fn main() {
8989
let config = Config::from_args();
90-
let lines = read_lines(&config.file)?;
90+
let lines = read_lines(&config.file).expect("Error when reading input");
9191
let data = parse_table_data(&lines, &config.separator);
9292

9393
if data.len() < 2 || data[0].len() == 0 {
94-
eprintln!("Bad Input: Table requires at least 2 rows (including header) and 1 column.");
94+
eprintln!("Bad Input: Requires at least 2 rows (including header) and 1 column.");
9595
std::process::exit(1);
9696
}
9797

@@ -100,8 +100,7 @@ fn main() -> Result<()> {
100100
false => format_pretty(&data),
101101
} + "\n";
102102
match config.out {
103-
Some(f) => fs::write(f, &table)?,
103+
Some(f) => fs::write(f, &table).expect("Error when writing output to file"),
104104
None => print!("{}", &table),
105105
};
106-
Ok(())
107106
}

0 commit comments

Comments
 (0)