Forward child process return code if possible

This commit is contained in:
Quantum 2024-10-15 02:02:39 -04:00
parent ffb1c1c8b5
commit 7e74fc8888

View file

@ -1,6 +1,7 @@
use crate::runner::CaptureError; use crate::runner::CaptureError;
use clap::Parser; use clap::Parser;
use runner::CapturedOutput; use runner::CapturedOutput;
use std::process::exit;
mod quote; mod quote;
mod runner; mod runner;
@ -210,7 +211,13 @@ async fn main() {
}; };
match request.send().await.and_then(|r| r.error_for_status()) { match request.send().await.and_then(|r| r.error_for_status()) {
Ok(_) => (), Ok(_) => exit(match status {
Err(error) => eprintln!("Failed to send request to ntfy: {}", error), Some(code) => code.code().unwrap_or(255),
None => 255,
}),
Err(error) => {
eprintln!("Failed to send request to ntfy: {}", error);
exit(37)
}
} }
} }