diff options
author | Canop <cano.petrole@gmail.com> | 2019-02-11 18:19:18 +0100 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2019-02-11 18:19:18 +0100 |
commit | 84bfc6b77846fd643f878c337fee23bb0b6153fc (patch) | |
tree | 9970107a79c9eb8f003579cae07b5c4bf73f7d93 /src/main.rs | |
parent | e87b5f654a5949eba90dc5aecc911ecd9105a671 (diff) |
handle errors on a few cases of non suitable root
* initial path not a file: display an error and exit
* initial path not a directory: open the parent instead
* directory removed between display and focus: display an error in
status
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs index 6efe5f2..15d8dd6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,11 +17,11 @@ mod external; mod file_sizes; mod flat_tree; mod fuzzy_patterns; -mod regex_patterns; mod git_ignore; mod help_states; mod input; mod patterns; +mod regex_patterns; mod screen_text; mod screens; mod shell_func; @@ -41,13 +41,12 @@ use std::result::Result; use std::str::FromStr; use crate::app::App; -use crate::app_context::{AppContext}; +use crate::app_context::AppContext; use crate::conf::Conf; use crate::errors::ProgramError; use crate::external::Launchable; use crate::verbs::VerbStore; - // There's no log unless the BROOT_LOG environment variable is set to // a valid log level (trace, debug, info, warn, error, off) // Example: @@ -65,7 +64,11 @@ fn configure_log() { File::create("dev.log").expect("Log file can't be created"), ) .expect("log initialization failed"); - info!("Starting B-Root v{} with log level {}", env!("CARGO_PKG_VERSION"), level); + info!( + "Starting B-Root v{} with log level {}", + env!("CARGO_PKG_VERSION"), + level + ); } } @@ -89,7 +92,15 @@ fn run() -> Result<Option<Launchable>, ProgramError> { } fn main() { - let res = run().unwrap(); + let res = match run() { + Ok(res) => res, + Err(e) => { + // this usually happens when the passed path isn't of a directory + warn!("Error: {}", e); + eprintln!("{}", e); + return; + } + }; if let Some(launchable) = res { info!("launching {:?}", &launchable); if let Err(e) = launchable.execute() { |