chore: notes on fixmes to improve error handling
Some checks failed
Test / build (map[name:nightly]) (push) Successful in 6m51s
Test / build (map[name:stable]) (push) Successful in 6m33s
Release Please / Release-plz (push) Failing after 50s

This commit is contained in:
Paul Campbell 2024-12-23 09:44:02 +00:00
parent 651bd656c2
commit d96dee302d
5 changed files with 16 additions and 16 deletions

View file

@ -53,9 +53,9 @@ impl Actor for ImportAttachmentActor {
// - - - download the attachment from trello // - - - download the attachment from trello
let dir_path = this.ctx.temp_fs.base().join(&*this.trello_attachment.id); let dir_path = this.ctx.temp_fs.base().join(&*this.trello_attachment.id);
let dir = this.ctx.temp_fs.dir(&dir_path); let dir = this.ctx.temp_fs.dir(&dir_path);
dir.create()?; dir.create()?; // FIXME: (#6) handle error
let file_path = dir_path.join(&*this.trello_attachment.name); let file_path = dir_path.join(&*this.trello_attachment.name);
ask!(this.rate_limit_actor, RequestToken)?; ask!(this.rate_limit_actor, RequestToken)?; // FIXME: (#6) handle error
let attachment_path = this let attachment_path = this
.ctx .ctx
.trello_client() .trello_client()
@ -66,7 +66,7 @@ impl Actor for ImportAttachmentActor {
&this.ctx.temp_fs, &this.ctx.temp_fs,
) )
.await .await
.with_context(|| f!("saving attachment {}", file_path.display()))?; .with_context(|| f!("saving attachment {}", file_path.display()))?; // FIXME: (#6) handle error
let attachment_file = this.ctx.temp_fs.file(&attachment_path); let attachment_file = this.ctx.temp_fs.file(&attachment_path);
// - - - upload the attachment to nextcloud card // - - - upload the attachment to nextcloud card
let attachment = this let attachment = this
@ -88,7 +88,7 @@ impl Actor for ImportAttachmentActor {
e.to_string() e.to_string()
); );
}) })
.with_context(|| f!("adding attachment to card {}", file_path.display()))?; .with_context(|| f!("adding attachment to card {}", file_path.display()))?; // FIXME: (#6) handle error
p!( p!(
this.ctx.prt, this.ctx.prt,
">> Attachment added: {}:{}", ">> Attachment added: {}:{}",
@ -99,9 +99,9 @@ impl Actor for ImportAttachmentActor {
// delete local copy of attachment // delete local copy of attachment
attachment_file attachment_file
.remove() .remove()
.with_context(|| f!("deleting temp file {attachment_file}"))?; .with_context(|| f!("deleting temp file {attachment_file}"))?; // FIXME: (#6) handle error
dir.remove() dir.remove()
.with_context(|| f!("deleting temp dir {dir}"))?; .with_context(|| f!("deleting temp dir {dir}"))?; // FIXME: (#6) handle error
Ok(actor_ref.stop_gracefully().await?) Ok(actor_ref.stop_gracefully().await?)
}); });

View file

@ -81,7 +81,7 @@ impl Actor for ImportCardActor {
desc.as_ref(), desc.as_ref(),
) )
.await .await
.result?; .result?; // FIXME: (#6) handle error
let mut limit = RateLimit::new("labels & attachments", 10, 10.0, this.ctx.now()); let mut limit = RateLimit::new("labels & attachments", 10, 10.0, this.ctx.now());

View file

@ -47,8 +47,8 @@ impl Actor for ImportLabelActor {
trello_name: this.trello_label.name.clone(), trello_name: this.trello_label.name.clone(),
trello_color: this.trello_label.color.clone() trello_color: this.trello_label.color.clone()
} }
)?; )?; // FIXME: (#6) handle error
// - - - add the label to the nextcloud card // - - - add the label to the nextcloud card
this.ctx this.ctx
.deck_client() .deck_client()
.add_label_to_card( .add_label_to_card(
@ -58,7 +58,7 @@ impl Actor for ImportLabelActor {
label_id, label_id,
) )
.await .await
.result?; .result?; // FIXME: (#6) handle error
Ok(actor_ref.stop_gracefully().await?) Ok(actor_ref.stop_gracefully().await?)
}); });

View file

@ -62,7 +62,7 @@ impl Actor for ImportStackActor {
crate::p!(this.ctx.prt, "Importing stack: {}", this.trello_stack.name); crate::p!(this.ctx.prt, "Importing stack: {}", this.trello_stack.name);
// - get the list of trello cards in the stack // - get the list of trello cards in the stack
ask!(this.rate_limit_actor, RequestToken)?; ask!(this.rate_limit_actor, RequestToken)?; // FIXME: (#6) handle error
let mut trello_cards = trello_client let mut trello_cards = trello_client
.list_cards(&TrelloListId::new(this.trello_stack.id.as_ref())) .list_cards(&TrelloListId::new(this.trello_stack.id.as_ref()))
.await .await
@ -75,7 +75,7 @@ impl Actor for ImportStackActor {
// - for each card in the trello stack // - for each card in the trello stack
for trello_card in trello_cards.into_iter() { for trello_card in trello_cards.into_iter() {
limit.block_until_token_available(this.ctx.now()).await; limit.block_until_token_available(this.ctx.now()).await;
ask!(this.rate_limit_actor, RequestToken)?; ask!(this.rate_limit_actor, RequestToken)?; // FIXME: (#6) handle error
let trello_card_name = trello_card.name.clone(); let trello_card_name = trello_card.name.clone();
let child: ActorRef<ImportCardActor> = spawn_in_thread!( let child: ActorRef<ImportCardActor> = spawn_in_thread!(
actor_ref.clone(), actor_ref.clone(),

View file

@ -33,9 +33,9 @@ async fn create_any_missing_stacks(
let missing_stacks = selected_trello_stacks let missing_stacks = selected_trello_stacks
.iter() .iter()
.filter(|trello_stack| { .filter(|trello_stack| {
!nextcloud_stacks !nextcloud_stacks.iter().any(|nextcloud_stack|
.iter() // FIXME: (#7) nextcloud title is limited to 100 characters
.any(|nextcloud_stack| nextcloud_stack.title.deref() == trello_stack.name.deref()) nextcloud_stack.title.deref() == trello_stack.name.deref())
}) })
.cloned() .cloned()
.collect::<Vec<_>>(); .collect::<Vec<_>>();
@ -55,7 +55,7 @@ async fn create_any_missing_stacks(
let stack = deck_client let stack = deck_client
.create_stack( .create_stack(
nextcloud_board_id, nextcloud_board_id,
(&missing_stack.name).into(), (&missing_stack.name).into(), // FIXME: (#7) limited to 100 characters
(&missing_stack.pos).into(), (&missing_stack.pos).into(),
) )
.await .await