diff options
author | Thomas Otto <th1000s@posteo.net> | 2021-10-18 17:15:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-18 11:15:58 -0400 |
commit | 4f5e3ebbd1106c5f8e418b5743e2166576c9f0a8 (patch) | |
tree | f736e587dc494212e919fc3f22697d236a132827 /src/config.rs | |
parent | 3a03d4b5eede9a6c342a61941dd78c38c3559824 (diff) |
Use fatal() to exit with errorcode 2 (#739)
* Fix two typos
* Dismantle two Pyramids of Doom
Use question mark operator instead
* Use fatal() to exit with errorcode 2
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/config.rs b/src/config.rs index 4074551b..15860a80 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,6 +1,5 @@ use std::collections::HashMap; use std::path::PathBuf; -use std::process; use regex::Regex; use structopt::clap; @@ -185,23 +184,21 @@ impl From<cli::Opt> for Config { .unwrap_or(0.0); let commit_regex = Regex::new(&opt.commit_regex).unwrap_or_else(|_| { - eprintln!( + fatal(format!( "Invalid commit-regex: {}. \ The value must be a valid Rust regular expression. \ See https://docs.rs/regex.", opt.commit_regex - ); - process::exit(1); + )); }); let tokenization_regex = Regex::new(&opt.tokenization_regex).unwrap_or_else(|_| { - eprintln!( + fatal(format!( "Invalid word-diff-regex: {}. \ The value must be a valid Rust regular expression. \ See https://docs.rs/regex.", opt.tokenization_regex - ); - process::exit(1); + )); }); let side_by_side_data = side_by_side::SideBySideData::new_sbs( @@ -613,13 +610,11 @@ pub fn user_supplied_option(option: &str, arg_matches: &clap::ArgMatches) -> boo } pub fn delta_unreachable(message: &str) -> ! { - let error_exit_code = 2; // This is also stored in Config. - eprintln!( + fatal(format!( "{} This should not be possible. \ Please report the bug at https://github.com/dandavison/delta/issues.", message - ); - process::exit(error_exit_code); + )); } #[cfg(test)] |