Skip to content

Commit

Permalink
feat: add more context to send_msg errors
Browse files Browse the repository at this point in the history
  • Loading branch information
link2xt committed Oct 19, 2024
1 parent 85d7c1f commit 5e58bf7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
8 changes: 6 additions & 2 deletions deltachat-jsonrpc/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1946,9 +1946,13 @@ impl CommandApi {

async fn send_msg(&self, account_id: u32, chat_id: u32, data: MessageData) -> Result<u32> {
let ctx = self.get_context(account_id).await?;
let mut message = data.create_message(&ctx).await?;
let mut message = data
.create_message(&ctx)
.await
.context("Failed to create message")?;
let msg_id = chat::send_msg(&ctx, ChatId::new(chat_id), &mut message)
.await?
.await
.context("Failed to send created message")?
.to_u32();
Ok(msg_id)
}
Expand Down
15 changes: 6 additions & 9 deletions deltachat-jsonrpc/src/api/types/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,16 +605,13 @@ impl MessageData {
message.set_location(latitude, longitude);
}
if let Some(id) = self.quoted_message_id {
let quoted_message = Message::load_from_db(context, MsgId::new(id))
.await
.context("Failed to load quoted message")?;
message
.set_quote(
context,
Some(
&Message::load_from_db(context, MsgId::new(id))
.await
.context("message to quote could not be loaded")?,
),
)
.await?;
.set_quote(context, Some(&quoted_message))
.await
.context("Failed to set quote")?;
} else if let Some(text) = self.quoted_text {
let protect = false;
message.set_quote_text(Some((text, protect)));
Expand Down
5 changes: 4 additions & 1 deletion src/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2941,7 +2941,10 @@ async fn prepare_send_msg(
);
message::update_msg_state(context, msg.id, MessageState::OutPending).await?;
}
create_send_msg_jobs(context, msg).await
let row_ids = create_send_msg_jobs(context, msg)
.await
.context("Failed to create send jobs")?;
Ok(row_ids)
}

/// Constructs jobs for sending a message and inserts them into the appropriate table.
Expand Down

0 comments on commit 5e58bf7

Please sign in to comment.