From 6e18f17b727b3bec2edf46c1bcbb16f80983397e Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sun, 14 Sep 2025 11:45:49 +0800 Subject: httpconnector: improve debug --- src/client/connector.rs | 16 +++++++++++++--- src/client/connector/connectors/httpconnector.rs | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/client/connector.rs b/src/client/connector.rs index 51b662a..e403317 100644 --- a/src/client/connector.rs +++ b/src/client/connector.rs @@ -5,14 +5,14 @@ use std::{thread::sleep, time::Duration}; use crate::executor::{Executor, tasks::IntoTask}; -pub(crate) enum Result { +pub(crate) enum Result { Ok(T), Err(E), } pub(crate) trait Connection { type Ok: std::fmt::Display + IntoTask + AsRef = String; - type Err: std::fmt::Display; + type Err: std::fmt::Debug; // should use channel to notify update fn update(&self) -> Result; // None if no update(content is same) @@ -49,7 +49,17 @@ pub(crate) trait Connection { .unwrap(), ); } - Result::Err(e) => eprintln!("Error: {}", e), + Result::Err(e) => { + #[cfg(debug_assertions)] + std::eprintln!( + "[{}:{}:{}] {} = {:#?}", + std::file!(), + std::line!(), + std::column!(), + std::stringify!(e), + &&e as &dyn std::fmt::Debug, + ); + } } } } diff --git a/src/client/connector/connectors/httpconnector.rs b/src/client/connector/connectors/httpconnector.rs index 5c1cc73..fb97cc4 100644 --- a/src/client/connector/connectors/httpconnector.rs +++ b/src/client/connector/connectors/httpconnector.rs @@ -48,6 +48,7 @@ impl HTTPConnector { } } +#[derive(Debug)] pub(crate) enum Err { Reqwest(Error), StatusCode(StatusCode), -- cgit v1.2.3