Print more anyhow errors with their causes

This commit is contained in:
link2xt
2023-01-04 14:37:12 +00:00
parent 2b4e32d2cf
commit 754c7324f5
11 changed files with 49 additions and 46 deletions

View File

@@ -1129,7 +1129,7 @@ impl Chat {
}
}
Err(err) => {
error!(context, "faild to load contacts for {}: {:?}", chat.id, err);
error!(context, "faild to load contacts for {}: {:#}", chat.id, err);
}
}
chat.name = chat_name;
@@ -2146,7 +2146,7 @@ async fn create_send_msg_job(context: &Context, msg_id: MsgId) -> Result<Option<
let attach_selfavatar = match shall_attach_selfavatar(context, msg.chat_id).await {
Ok(attach_selfavatar) => attach_selfavatar,
Err(err) => {
warn!(context, "job: cannot get selfavatar-state: {}", err);
warn!(context, "job: cannot get selfavatar-state: {:#}", err);
false
}
};
@@ -2208,27 +2208,27 @@ async fn create_send_msg_job(context: &Context, msg_id: MsgId) -> Result<Option<
if 0 != rendered_msg.last_added_location_id {
if let Err(err) = location::set_kml_sent_timestamp(context, msg.chat_id, time()).await {
error!(context, "Failed to set kml sent_timestamp: {:?}", err);
error!(context, "Failed to set kml sent_timestamp: {:#}", err);
}
if !msg.hidden {
if let Err(err) =
location::set_msg_location_id(context, msg.id, rendered_msg.last_added_location_id)
.await
{
error!(context, "Failed to set msg_location_id: {:?}", err);
error!(context, "Failed to set msg_location_id: {:#}", err);
}
}
}
if let Some(sync_ids) = rendered_msg.sync_ids_to_delete {
if let Err(err) = context.delete_sync_ids(sync_ids).await {
error!(context, "Failed to delete sync ids: {:?}", err);
error!(context, "Failed to delete sync ids: {:#}", err);
}
}
if attach_selfavatar {
if let Err(err) = msg.chat_id.set_selfavatar_timestamp(context, time()).await {
error!(context, "Failed to set selfavatar timestamp: {:?}", err);
error!(context, "Failed to set selfavatar timestamp: {:#}", err);
}
}

View File

@@ -383,7 +383,7 @@ impl Context {
let mut lock = self.inner.scheduler.write().await;
if lock.is_none() {
match Scheduler::start(self.clone()).await {
Err(err) => error!(self, "Failed to start IO: {}", err),
Err(err) => error!(self, "Failed to start IO: {:#}", err),
Ok(scheduler) => *lock = Some(scheduler),
}
}
@@ -499,7 +499,7 @@ impl Context {
match &*s {
RunningState::Running { cancel_sender } => {
if let Err(err) = cancel_sender.send(()).await {
warn!(self, "could not cancel ongoing: {:?}", err);
warn!(self, "could not cancel ongoing: {:#}", err);
}
info!(self, "Signaling the ongoing process to stop ASAP.",);
*s = RunningState::ShallStop;

View File

@@ -132,7 +132,7 @@ impl Job {
/// Called in response to `Action::DownloadMsg`.
pub(crate) async fn download_msg(&self, context: &Context, imap: &mut Imap) -> Status {
if let Err(err) = imap.prepare(context).await {
warn!(context, "download: could not connect: {:?}", err);
warn!(context, "download: could not connect: {:#}", err);
return Status::RetryNow;
}

View File

@@ -250,7 +250,7 @@ impl MsgId {
if !rawmime.is_empty() {
match HtmlMsgParser::from_bytes(context, &rawmime).await {
Err(err) => {
warn!(context, "get_html: parser error: {}", err);
warn!(context, "get_html: parser error: {:#}", err);
Ok(None)
}
Ok(parser) => Ok(Some(parser.html)),

View File

@@ -157,7 +157,7 @@ impl Job {
/// Synchronizes UIDs for all folders.
async fn resync_folders(&mut self, context: &Context, imap: &mut Imap) -> Status {
if let Err(err) = imap.prepare(context).await {
warn!(context, "could not connect: {:?}", err);
warn!(context, "could not connect: {:#}", err);
return Status::RetryLater;
}
@@ -246,7 +246,7 @@ pub(crate) async fn perform_job(context: &Context, mut connection: Connection<'_
time_offset
);
job.save(context).await.unwrap_or_else(|err| {
error!(context, "failed to save job: {}", err);
error!(context, "failed to save job: {:#}", err);
});
} else {
info!(
@@ -254,7 +254,7 @@ pub(crate) async fn perform_job(context: &Context, mut connection: Connection<'_
"remove job {} as it exhausted {} retries", job, JOB_RETRIES
);
job.delete(context).await.unwrap_or_else(|err| {
error!(context, "failed to delete job: {}", err);
error!(context, "failed to delete job: {:#}", err);
});
}
}
@@ -269,7 +269,7 @@ pub(crate) async fn perform_job(context: &Context, mut connection: Connection<'_
}
job.delete(context).await.unwrap_or_else(|err| {
error!(context, "failed to delete job: {}", err);
error!(context, "failed to delete job: {:#}", err);
});
}
}
@@ -403,7 +403,7 @@ LIMIT 1;
Ok(job) => return Ok(job),
Err(err) => {
// Remove invalid job from the DB
info!(context, "cleaning up job, because of {}", err);
info!(context, "cleaning up job, because of {:#}", err);
// TODO: improve by only doing a single query
let id = context

View File

@@ -337,7 +337,7 @@ pub async fn set(context: &Context, latitude: f64, longitude: f64, accuracy: f64
ContactId::SELF,
]
).await {
warn!(context, "failed to store location {:?}", err);
warn!(context, "failed to store location {:#}", err);
} else {
info!(context, "stored location for chat {}", chat_id);
continue_streaming = true;
@@ -638,7 +638,7 @@ pub(crate) async fn location_loop(context: &Context, interrupt_receiver: Receive
loop {
let next_event = match maybe_send_locations(context).await {
Err(err) => {
warn!(context, "maybe_send_locations failed: {}", err);
warn!(context, "maybe_send_locations failed: {:#}", err);
Some(60) // Retry one minute later.
}
Ok(next_event) => next_event,

View File

@@ -1687,7 +1687,7 @@ pub async fn get_unblocked_msg_cnt(context: &Context) -> usize {
{
Ok(res) => res,
Err(err) => {
error!(context, "get_unblocked_msg_cnt() failed. {}", err);
error!(context, "get_unblocked_msg_cnt() failed. {:#}", err);
0
}
}
@@ -1707,7 +1707,7 @@ pub async fn get_request_msg_cnt(context: &Context) -> usize {
{
Ok(res) => res,
Err(err) => {
error!(context, "get_request_msg_cnt() failed. {}", err);
error!(context, "get_request_msg_cnt() failed. {:#}", err);
0
}
}

View File

@@ -251,7 +251,7 @@ impl MimeMessage {
}
Ok(None) => (Ok(mail), HashSet::new(), false),
Err(err) => {
warn!(context, "decryption failed: {}", err);
warn!(context, "decryption failed: {:#}", err);
(Err(err), HashSet::new(), false)
}
};
@@ -380,7 +380,7 @@ impl MimeMessage {
typ: Viewtype::Text,
msg_raw: Some(txt.clone()),
msg: txt,
error: Some(format!("Decrypting failed: {}", err)),
error: Some(format!("Decrypting failed: {:#}", err)),
..Default::default()
};
parser.parts.push(part);
@@ -680,7 +680,7 @@ impl MimeMessage {
Err(err) => {
warn!(
context,
"Could not save decoded avatar to blob file: {}", err
"Could not save decoded avatar to blob file: {:#}", err
);
None
}
@@ -987,7 +987,7 @@ impl MimeMessage {
let decoded_data = match mail.get_body() {
Ok(decoded_data) => decoded_data,
Err(err) => {
warn!(context, "Invalid body parsed {:?}", err);
warn!(context, "Invalid body parsed {:#}", err);
// Note that it's not always an error - might be no data
return Ok(false);
}
@@ -1007,7 +1007,7 @@ impl MimeMessage {
let decoded_data = match mail.get_body() {
Ok(decoded_data) => decoded_data,
Err(err) => {
warn!(context, "Invalid body parsed {:?}", err);
warn!(context, "Invalid body parsed {:#}", err);
// Note that it's not always an error - might be no data
return Ok(false);
}
@@ -1139,7 +1139,7 @@ impl MimeMessage {
if filename.starts_with("location") || filename.starts_with("message") {
let parsed = location::Kml::parse(decoded_data)
.map_err(|err| {
warn!(context, "failed to parse kml part: {}", err);
warn!(context, "failed to parse kml part: {:#}", err);
})
.ok();
if filename.starts_with("location") {
@@ -1157,7 +1157,7 @@ impl MimeMessage {
self.sync_items = context
.parse_sync_items(serialized)
.map_err(|err| {
warn!(context, "failed to parse sync data: {}", err);
warn!(context, "failed to parse sync data: {:#}", err);
})
.ok();
return Ok(());
@@ -1179,7 +1179,7 @@ impl MimeMessage {
Err(err) => {
error!(
context,
"Could not add blob for mime part {}, error {}", filename, err
"Could not add blob for mime part {}, error {:#}", filename, err
);
return Ok(());
}
@@ -1224,7 +1224,7 @@ impl MimeMessage {
Err(err) => {
warn!(
context,
"PGP key attachment is not an ASCII-armored file: {}", err,
"PGP key attachment is not an ASCII-armored file: {:#}", err
);
return Ok(false);
}

View File

@@ -134,7 +134,7 @@ impl Context {
/// Called in response to `Action::UpdateRecentQuota`.
pub(crate) async fn update_recent_quota(&self, imap: &mut Imap) -> Result<Status> {
if let Err(err) = imap.prepare(self).await {
warn!(self, "could not connect: {:?}", err);
warn!(self, "could not connect: {:#}", err);
return Ok(Status::RetryNow);
}
@@ -162,7 +162,7 @@ impl Context {
self.set_config(Config::QuotaExceeding, None).await?;
}
}
Err(err) => warn!(self, "cannot get highest quota usage: {:?}", err),
Err(err) => warn!(self, "cannot get highest quota usage: {:#}", err),
}
}

View File

@@ -102,7 +102,7 @@ pub(crate) async fn receive_imf_inner(
let mut mime_parser =
match MimeMessage::from_bytes_with_partial(context, imf_raw, is_partial_download).await {
Err(err) => {
warn!(context, "receive_imf: can't parse MIME: {}", err);
warn!(context, "receive_imf: can't parse MIME: {:#}", err);
let msg_ids;
if !rfc724_mid.starts_with(GENERATED_PREFIX) {
let row_id = context
@@ -253,7 +253,7 @@ pub(crate) async fn receive_imf_inner(
if from_id == ContactId::SELF {
if mime_parser.was_encrypted() {
if let Err(err) = context.execute_sync_items(sync_items).await {
warn!(context, "receive_imf cannot execute sync items: {}", err);
warn!(context, "receive_imf cannot execute sync items: {:#}", err);
}
} else {
warn!(context, "sync items are not encrypted.");
@@ -268,7 +268,7 @@ pub(crate) async fn receive_imf_inner(
.receive_status_update(from_id, insert_msg_id, status_update)
.await
{
warn!(context, "receive_imf cannot update status: {}", err);
warn!(context, "receive_imf cannot update status: {:#}", err);
}
}
@@ -290,7 +290,10 @@ pub(crate) async fn receive_imf_inner(
context.emit_event(EventType::ChatModified(chat_id));
}
Err(err) => {
warn!(context, "receive_imf cannot update profile image: {}", err);
warn!(
context,
"receive_imf cannot update profile image: {:#}", err
);
}
};
}
@@ -317,7 +320,7 @@ pub(crate) async fn receive_imf_inner(
)
.await
{
warn!(context, "cannot update contact status: {}", err);
warn!(context, "cannot update contact status: {:#}", err);
}
}
@@ -495,7 +498,7 @@ async fn add_parts(
securejoin_seen = false;
}
Err(err) => {
warn!(context, "Error in Secure-Join message handling: {}", err);
warn!(context, "Error in Secure-Join message handling: {:#}", err);
chat_id = Some(DC_CHAT_ID_TRASH);
securejoin_seen = true;
}
@@ -730,7 +733,7 @@ async fn add_parts(
chat_id = None;
}
Err(err) => {
warn!(context, "Error in Secure-Join watching: {}", err);
warn!(context, "Error in Secure-Join watching: {:#}", err);
chat_id = Some(DC_CHAT_ID_TRASH);
}
}
@@ -870,7 +873,7 @@ async fn add_parts(
Err(err) => {
warn!(
context,
"can't parse ephemeral timer \"{}\": {}", value, err
"can't parse ephemeral timer \"{}\": {:#}", value, err
);
EphemeralTimer::Disabled
}
@@ -926,7 +929,7 @@ async fn add_parts(
{
warn!(
context,
"failed to modify timer for chat {}: {}", chat_id, err
"failed to modify timer for chat {}: {:#}", chat_id, err
);
} else {
info!(
@@ -975,7 +978,7 @@ async fn add_parts(
if chat.is_protected() || new_status.is_some() {
if let Err(err) = check_verified_properties(context, mime_parser, from_id, to_ids).await
{
warn!(context, "verification problem: {}", err);
warn!(context, "verification problem: {:#}", err);
let s = format!("{}. See 'Info' for more details", err);
mime_parser.repl_msg_by_error(&s);
} else {
@@ -1487,7 +1490,7 @@ async fn create_or_lookup_group(
let create_protected = if mime_parser.get_header(HeaderDef::ChatVerified).is_some() {
if let Err(err) = check_verified_properties(context, mime_parser, from_id, to_ids).await {
warn!(context, "verification problem: {}", err);
warn!(context, "verification problem: {:#}", err);
let s = format!("{}. See 'Info' for more details", err);
mime_parser.repl_msg_by_error(&s);
}
@@ -1685,7 +1688,7 @@ async fn apply_group_changes(
if mime_parser.get_header(HeaderDef::ChatVerified).is_some() {
if let Err(err) = check_verified_properties(context, mime_parser, from_id, to_ids).await {
warn!(context, "verification problem: {}", err);
warn!(context, "verification problem: {:#}", err);
let s = format!("{}. See 'Info' for more details", err);
mime_parser.repl_msg_by_error(&s);
}

View File

@@ -626,26 +626,26 @@ pub async fn housekeeping(context: &Context) -> Result<()> {
if let Err(err) = remove_unused_files(context).await {
warn!(
context,
"Housekeeping: cannot remove unusued files: {}", err
"Housekeeping: cannot remove unusued files: {:#}", err
);
}
if let Err(err) = start_ephemeral_timers(context).await {
warn!(
context,
"Housekeeping: cannot start ephemeral timers: {}", err
"Housekeeping: cannot start ephemeral timers: {:#}", err
);
}
if let Err(err) = prune_tombstones(&context.sql).await {
warn!(
context,
"Housekeeping: Cannot prune message tombstones: {}", err
"Housekeeping: Cannot prune message tombstones: {:#}", err
);
}
if let Err(err) = deduplicate_peerstates(&context.sql).await {
warn!(context, "Failed to deduplicate peerstates: {}", err)
warn!(context, "Failed to deduplicate peerstates: {:#}", err)
}
context.schedule_quota_update().await?;