diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-02-20 18:52:35 +0100 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-02-20 18:52:35 +0100 |
commit | 4ff1b3816194543aba53512f559e144979227f3d (patch) | |
tree | 7ee5226eed75f0e7c7dd588317228f3928ab948a | |
parent | 767192c7a1afaa7265ccb706671785f2c9d9f02f (diff) |
proper early error handling
-rw-r--r-- | src/main.rs | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index e9f1f8a..1f0ec29 100644 --- a/src/main.rs +++ b/src/main.rs @@ -48,11 +48,29 @@ fn start() -> anyhow::Result<()> { fn main() -> ExitCode { let mut stdout = StandardStream::stdout(ColorChoice::Always); - let _mount = Mount::builder() + let _mount; + + match Mount::builder() .fstype("vfat") .mount("/dev/disk/by-partuuid/00000000-01", "/boot") - .expect("can't mount boot partition") - .into_unmount_drop(UnmountFlags::DETACH); + { + Ok(v) => _mount = v.into_unmount_drop(UnmountFlags::DETACH), + Err(e) => { + match stdout.set_color(ColorSpec::new().set_fg(Some(Color::Red))) { + Ok(_) => match writeln!(&mut stdout, "[ ERROR ] Can't mount /boot: {}", e) { + Ok(_) => {} + Err(_) => println!("[ ERROR ] Can't mount /boot: {}", e), + }, + Err(_) => { + println!("[ ERROR ] Can't mount /boot: {}", e); + } + } + + loop { + thread::sleep(Duration::MAX); + } + } + }; if process::id() != 1 { match stdout.set_color(ColorSpec::new().set_fg(Some(Color::Red))) { @@ -65,7 +83,9 @@ fn main() -> ExitCode { } } - return ExitCode::FAILURE; + loop { + thread::sleep(Duration::MAX); + } } match start() { |