Add panic subcommand to check backtraces
Browse files at this commitec2d339a86f8c3c38de8c9f3d47274bf3601779dParent: 629a2cc2 changed files +10 -1
- src/main.rs +4 -1
- src/utils.rs +6 -0
src/main.rsmodified+4 -1
| @@ -40,7 +40,7 @@ use tracing_subscriber::EnvFilter; | |||
| 40 | use utils::spawn; | 40 | use utils::spawn; |
| 41 | use watcher::Watcher; | 41 | use watcher::Watcher; |
| 42 | 42 | ||
| 43 | -use crate::utils::{REMOVE_ENV_RUST_BACKTRACE, REMOVE_ENV_RUST_LIB_BACKTRACE}; | 43 | +use crate::utils::{cause_panic, REMOVE_ENV_RUST_BACKTRACE, REMOVE_ENV_RUST_LIB_BACKTRACE}; |
| 44 | 44 | ||
| 45 | #[derive(Parser)] | 45 | #[derive(Parser)] |
| 46 | #[command(author, version, about, long_about = None)] | 46 | #[command(author, version, about, long_about = None)] |
| @@ -67,6 +67,8 @@ enum Sub { | |||
| 67 | #[arg(short, long)] | 67 | #[arg(short, long)] |
| 68 | config: Option<PathBuf>, | 68 | config: Option<PathBuf>, |
| 69 | }, | 69 | }, |
| 70 | + /// Cause a panic to check if the backtraces are good. | ||
| 71 | + Panic, | ||
| 70 | } | 72 | } |
| 71 | 73 | ||
| 72 | fn main() -> Result<(), Box<dyn std::error::Error>> { | 74 | fn main() -> Result<(), Box<dyn std::error::Error>> { |
| @@ -118,6 +120,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { | |||
| 118 | info!("config is valid"); | 120 | info!("config is valid"); |
| 119 | return Ok(()); | 121 | return Ok(()); |
| 120 | } | 122 | } |
| 123 | + Sub::Panic => cause_panic(), | ||
| 121 | } | 124 | } |
| 122 | } | 125 | } |
| 123 | 126 | ||
src/utils.rsmodified+6 -0
| @@ -190,3 +190,9 @@ pub fn show_screenshot_notification(image_path: Option<PathBuf>) { | |||
| 190 | warn!("error showing screenshot notification: {err:?}"); | 190 | warn!("error showing screenshot notification: {err:?}"); |
| 191 | } | 191 | } |
| 192 | } | 192 | } |
| 193 | + | ||
| 194 | +pub fn cause_panic() { | ||
| 195 | + let a = Duration::from_secs(1); | ||
| 196 | + let b = Duration::from_secs(2); | ||
| 197 | + let _ = a - b; | ||
| 198 | +} | ||