Skip to content

Commit 4f87a78

Browse files
committed
clarify what the error handler does
1 parent d2d35af commit 4f87a78

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ fn main() {
1212
match open::that(&path_or_url) {
1313
Ok(status) if status.success() => (),
1414
Ok(status) => match status.code() {
15-
Some(code) => open_error(code, &path_or_url, &format!("error code: {}", code)),
16-
None => open_error(3, &path_or_url, "error unknown"),
15+
Some(code) => print_error_and_exit(code, &path_or_url, &format!("error code: {}", code)),
16+
None => print_error_and_exit(3, &path_or_url, "error unknown"),
1717
},
18-
Err(err) => open_error(3, &path_or_url, &err.to_string()),
18+
Err(err) => print_error_and_exit(3, &path_or_url, &err.to_string()),
1919
}
2020
}
2121

22-
fn open_error(code: i32, path: &str, error_message: &str) {
22+
fn print_error_and_exit(code: i32, path: &str, error_message: &str) -> ! {
2323
eprintln!(
2424
"An error occurred when opening '{}': {}",
2525
path, error_message

0 commit comments

Comments
 (0)