diff --git a/src/main.rs b/src/main.rs index aa228f6..2618042 100644 --- a/src/main.rs +++ b/src/main.rs @@ -71,7 +71,6 @@ mod utils; use std::sync::Arc; -use color_eyre::eyre::WrapErr as _; use tracing_subscriber::{ layer::SubscriberExt as _, util::SubscriberInitExt as _, }; @@ -158,7 +157,7 @@ async fn download_output_dependencies( } while let Some(task) = output_dependencies_tasks.join_next().await { - task.wrap_err("output dependencies task panicked or was cancelled")??; + task??; } Ok(()) } @@ -272,15 +271,13 @@ async fn run_with_tui( config: Arc, logging_filter: tracing_subscriber::filter::Targets, ) -> crate::Result<()> { - tui_logger::init_logger(tui_logger::LevelFilter::Debug) - .wrap_err("failed to initialize tui_logger")?; + tui_logger::init_logger(tui_logger::LevelFilter::Debug)?; tracing_subscriber::registry() .with(logging_filter) .with(tui_logger::TuiTracingSubscriberLayer) .init(); - let terminal = - ratatui::try_init().wrap_err("failed to initialize ratatui")?; + let terminal = ratatui::try_init()?; let terminal_guard = tui::RatatuiRestoreGuard; let token = tokio_util::sync::CancellationToken::new(); @@ -325,7 +322,7 @@ async fn main() -> crate::Result<()> { #[cfg(feature = "dhat")] let _profiler = dhat::Profiler::new_heap(); - color_eyre::install().wrap_err("failed to install color_eyre hooks")?; + color_eyre::install()?; let config = config::load_config().await?; let logging_filter = create_logging_filter(&config); diff --git a/src/output.rs b/src/output.rs index eb82a51..9b8453c 100644 --- a/src/output.rs +++ b/src/output.rs @@ -105,17 +105,10 @@ pub async fn save_proxies( exit_ip: proxy.exit_ip.as_deref(), asn: if let Some(asn_db) = &maybe_asn_db { if let Some(exit_ip) = proxy.exit_ip.as_ref() { - let exit_ip_addr: IpAddr = exit_ip.parse().wrap_err( - "failed to parse proxy's exit ip as IpAddr", - )?; - asn_db - .lookup::>(exit_ip_addr) - .wrap_err_with(move || { - format!( - "failed to lookup {exit_ip_addr} in ASN \ - database" - ) - })? + let exit_ip_addr: IpAddr = exit_ip.parse()?; + asn_db.lookup::>( + exit_ip_addr, + )? } else { None } @@ -124,17 +117,10 @@ pub async fn save_proxies( }, geolocation: if let Some(geo_db) = &maybe_geo_db { if let Some(exit_ip) = proxy.exit_ip.as_ref() { - let exit_ip_addr: IpAddr = exit_ip.parse().wrap_err( - "failed to parse proxy's exit ip as IpAddr", - )?; - geo_db - .lookup::>(exit_ip_addr) - .wrap_err_with(move || { - format!( - "failed to lookup {exit_ip_addr} in \ - geolocation database" - ) - })? + let exit_ip_addr: IpAddr = exit_ip.parse()?; + geo_db.lookup::>( + exit_ip_addr, + )? } else { None } @@ -156,11 +142,9 @@ pub async fn save_proxies( }), }?; let json_data = if pretty { - serde_json::to_vec_pretty(&proxy_dicts) - .wrap_err("failed to serialize proxies to pretty json")? + serde_json::to_vec_pretty(&proxy_dicts)? } else { - serde_json::to_vec(&proxy_dicts) - .wrap_err("failed to serialize proxies to json")? + serde_json::to_vec(&proxy_dicts)? }; tokio::fs::write(&path, json_data).await.wrap_err_with( move || { diff --git a/src/scraper.rs b/src/scraper.rs index 11a631d..ee524d5 100644 --- a/src/scraper.rs +++ b/src/scraper.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use color_eyre::eyre::{OptionExt as _, WrapErr as _}; +use color_eyre::eyre::OptionExt as _; use foldhash::HashSetExt as _; #[cfg(feature = "tui")] @@ -190,8 +190,7 @@ pub async fn scrape_all( drop(tx); while let Some(res) = join_set.join_next().await { - res.wrap_err("proxy scraping task panicked or was cancelled")? - .wrap_err("proxy scraping task failed")?; + res??; } drop(join_set); diff --git a/src/tui.rs b/src/tui.rs index 8f05bcc..ae87b74 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -52,8 +52,7 @@ pub async fn run( if let Some(event) = rx.recv().await { if handle_event(event, &mut app_state, &token, &logger_state) { terminal - .draw(|frame| draw(frame, &app_state, &logger_state)) - .wrap_err("failed to draw tui")?; + .draw(|frame| draw(frame, &app_state, &logger_state))?; } } else { break;