diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-09-14 11:45:49 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-09-14 11:45:49 +0800 |
| commit | 6e18f17b727b3bec2edf46c1bcbb16f80983397e (patch) | |
| tree | b920021a859e90aea075575d4df4138e1bb70da6 /src | |
| parent | e80250d00d62761d80b6caf9750dd5b7e80af8ef (diff) | |
httpconnector: improve debug
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/connector.rs | 16 | ||||
| -rw-r--r-- | src/client/connector/connectors/httpconnector.rs | 1 |
2 files changed, 14 insertions, 3 deletions
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<T: std::fmt::Display + IntoTask, E: std::fmt::Display> { +pub(crate) enum Result<T: std::fmt::Display + IntoTask, E: std::fmt::Debug> { Ok(T), Err(E), } pub(crate) trait Connection { type Ok: std::fmt::Display + IntoTask + AsRef<str> = String; - type Err: std::fmt::Display; + type Err: std::fmt::Debug; // should use channel to notify update fn update(&self) -> Result<Self::Ok, Self::Err>; // 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), |
