Skip to content
This repository was archived by the owner on Oct 11, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
handle errors in the companion's merge
  • Loading branch information
joao-paulo-parity committed Oct 1, 2021
commit 64635b3e404761ba83a6beb5ddaed2cc4a8232b5
28 changes: 24 additions & 4 deletions src/companion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,17 +461,37 @@ pub async fn merge_companions(
merge_done_in,
)
.await
.map_err(|err| {
format!("{} failed: {:?}", html_url, err)
.map_err(|err| CompanionDetailsWithErrorMessage {
owner: owner.to_owned(),
repo: repo.to_owned(),
number: *number,
html_url: html_url.to_owned(),
msg: format!(
"Companion update failed: {:?}",
err
),
})
})
})
.collect::<Vec<_>>();
while !remaining_futures.is_empty() {
let (result, _, next_remaining_futures) =
futures::future::select_all(remaining_futures).await;
if let Err(err_msg) = result {
errors.push(err_msg);
if let Err(CompanionDetailsWithErrorMessage {
ref owner,
ref repo,
ref number,
ref html_url,
ref msg,
}) = result
{
let _ = github_bot
.create_issue_comment(owner, repo, *number, msg)
.await
.map_err(|e| {
log::error!("Error posting comment: {}", e);
});
errors.push(format!("{} {}", html_url, msg));
}
remaining_futures = next_remaining_futures;
}
Expand Down
8 changes: 8 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ pub type IssueDetails = (String, String, i64);
// TODO this really should be struct { repository_url, repository, owner, number }
pub type IssueDetailsWithRepositoryURL = (String, String, String, i64);

pub struct CompanionDetailsWithErrorMessage {
pub owner: String,
pub repo: String,
pub number: i64,
pub html_url: String,
pub msg: String,
}

#[derive(Debug, Snafu)]
#[snafu(visibility = "pub")]
pub enum Error {
Expand Down