mirror of
https://github.com/localsend/localsend.git
synced 2026-08-07 07:14:52 +00:00
feat: more descriptive debug error
This commit is contained in:
@@ -7,6 +7,7 @@ use localsend::discovery::{
|
||||
};
|
||||
use localsend::model::discovery::{DeviceType, ProtocolType};
|
||||
use localsend::multicast::{DEFAULT_MULTICAST_GROUP_V6, InterfaceFilter, MulticastDevice};
|
||||
use localsend::util::error::ErrorChain;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use tokio::sync::{Mutex, mpsc, oneshot};
|
||||
@@ -302,7 +303,11 @@ impl RsDiscovery {
|
||||
match self.instance.handle.discover(&host, port, protocol).await {
|
||||
Ok(found) => found.map(rs_stored_device),
|
||||
Err(err) => {
|
||||
tracing::debug!("Could not discover {host}:{port}: {err:#}");
|
||||
tracing::debug!(
|
||||
"Could not discover {}://{host}:{port}: {}",
|
||||
protocol.as_str(),
|
||||
ErrorChain(&err)
|
||||
);
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ pub use localsend::http::dto::{
|
||||
};
|
||||
use localsend::model::discovery::ProtocolType;
|
||||
use localsend::reqwest;
|
||||
use localsend::util::error::ErrorChain;
|
||||
|
||||
pub struct RsHttpClient {
|
||||
inner: localsend::http::client::LsHttpClient,
|
||||
@@ -231,7 +232,7 @@ impl From<ClientError> for RsHttpClientError {
|
||||
status: e.status,
|
||||
message: e.message,
|
||||
},
|
||||
ClientError::Reqwest(e) => RsHttpClientError::Reqwest(error_chain(&e)),
|
||||
ClientError::Reqwest(e) => RsHttpClientError::Reqwest(ErrorChain(&e).to_string()),
|
||||
ClientError::Json(e) => RsHttpClientError::Json(e.to_string()),
|
||||
ClientError::Io(e) => RsHttpClientError::Io(e.to_string()),
|
||||
ClientError::Other(e) => RsHttpClientError::Other(e.to_string()),
|
||||
@@ -240,21 +241,6 @@ impl From<ClientError> for RsHttpClientError {
|
||||
}
|
||||
}
|
||||
|
||||
/// Renders an error together with everything that caused it.
|
||||
///
|
||||
/// [`reqwest::Error`] alone only says "error sending request for url (...)".
|
||||
pub(crate) fn error_chain(e: &dyn std::error::Error) -> String {
|
||||
use std::fmt::Write;
|
||||
|
||||
let mut message = e.to_string();
|
||||
let mut source = e.source();
|
||||
while let Some(current) = source {
|
||||
let _ = write!(message, ": {current}");
|
||||
source = current.source();
|
||||
}
|
||||
message
|
||||
}
|
||||
|
||||
#[frb(mirror(LsHttpClientVersion))]
|
||||
pub enum _LsHttpClientVersion {
|
||||
V2,
|
||||
|
||||
Reference in New Issue
Block a user