mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-09-10 07:32:49 +02:00
feat(fed): Something about nicer fed errors
This commit is contained in:
parent
e991a10de2
commit
b45b630af7
1 changed files with 15 additions and 3 deletions
|
@ -1,4 +1,8 @@
|
|||
use std::{fmt::Debug, mem};
|
||||
use std::{
|
||||
error::Error as _,
|
||||
fmt::{Debug, Write},
|
||||
mem,
|
||||
};
|
||||
|
||||
use bytes::Bytes;
|
||||
use conduwuit::{
|
||||
|
@ -193,9 +197,9 @@ fn handle_error(
|
|||
) -> Result {
|
||||
if e.is_timeout() || e.is_connect() {
|
||||
e = e.without_url();
|
||||
debug_warn!(?url, "network error while sending request: {e:?}");
|
||||
warn!(?url, "network error while sending federation request: {e:?}");
|
||||
} else if e.is_redirect() {
|
||||
debug_error!(
|
||||
warn!(
|
||||
method = ?method,
|
||||
url = ?url,
|
||||
final_url = ?e.url(),
|
||||
|
@ -207,6 +211,14 @@ fn handle_error(
|
|||
warn!(?url, "failed to send federation request: {e:?}");
|
||||
}
|
||||
|
||||
let mut nice_error = "Request failed".to_owned();
|
||||
let mut src = e.source();
|
||||
while let Some(source) = src {
|
||||
write!(nice_error, ": {source:?}").expect("writing to string should not fail");
|
||||
src = source.source();
|
||||
}
|
||||
warn!(nice_error, "Federation request error");
|
||||
|
||||
Err(e.into())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue