aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-01-09 08:08:38 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-01-09 08:08:38 +0400
commitec2d339a86f8c3c38de8c9f3d47274bf3601779d (patch)
tree849fdd30b985d89e5d74f33def2267dedd3e73c3
parent629a2ccb47a733ef1dcc912258d7ca46928f9d32 (diff)
downloadniri-ec2d339a86f8c3c38de8c9f3d47274bf3601779d.tar.gz
niri-ec2d339a86f8c3c38de8c9f3d47274bf3601779d.tar.bz2
niri-ec2d339a86f8c3c38de8c9f3d47274bf3601779d.zip
Add panic subcommand to check backtraces
-rw-r--r--src/main.rs5
-rw-r--r--src/utils.rs6
2 files changed, 10 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index c3cf8951..427e75b2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -40,7 +40,7 @@ use tracing_subscriber::EnvFilter;
use utils::spawn;
use watcher::Watcher;
-use crate::utils::{REMOVE_ENV_RUST_BACKTRACE, REMOVE_ENV_RUST_LIB_BACKTRACE};
+use crate::utils::{cause_panic, REMOVE_ENV_RUST_BACKTRACE, REMOVE_ENV_RUST_LIB_BACKTRACE};
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
@@ -67,6 +67,8 @@ enum Sub {
#[arg(short, long)]
config: Option<PathBuf>,
},
+ /// Cause a panic to check if the backtraces are good.
+ Panic,
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -118,6 +120,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
info!("config is valid");
return Ok(());
}
+ Sub::Panic => cause_panic(),
}
}
diff --git a/src/utils.rs b/src/utils.rs
index e43ba67d..ddd38dc6 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -190,3 +190,9 @@ pub fn show_screenshot_notification(image_path: Option<PathBuf>) {
warn!("error showing screenshot notification: {err:?}");
}
}
+
+pub fn cause_panic() {
+ let a = Duration::from_secs(1);
+ let b = Duration::from_secs(2);
+ let _ = a - b;
+}