Skip to content

Commit 9393844

Browse files
committed
Improve error context
1 parent d0172c5 commit 9393844

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/handlers/assign.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -579,22 +579,27 @@ pub(super) async fn handle_command(
579579
let pr = ctx
580580
.github
581581
.pull_request(issue.repository(), issue.number)
582-
.await?;
583-
let Some(diff) = pr.diff(&ctx.github).await? else {
582+
.await
583+
.context("Cannot load pull request from GitHub")?;
584+
let Some(diff) = pr.diff(&ctx.github).await.context("Cannot load PR diff")? else {
584585
bail!(
585586
"expected issue {} to be a PR, but the diff could not be determined",
586587
issue.number
587588
);
588589
};
589590

590591
let (assignee, _) =
591-
determine_assignee(ctx, None, issue, &event.user().login, config, diff).await?;
592+
determine_assignee(ctx, None, issue, &event.user().login, config, diff)
593+
.await
594+
.context("Cannot determine assignee when rerolling")?;
592595
if let Some(assignee) = assignee {
593-
set_assignee(ctx, issue, &ctx.github, &assignee).await?;
596+
set_assignee(ctx, issue, &ctx.github, &assignee)
597+
.await
598+
.context("Cannot set assignee when rerolling")?;
594599
} else {
595-
issue
596-
.post_comment(&ctx.github, "Cannot determine a new reviewer. Use `r? <username or team>` to request a specific reviewer or a team.")
597-
.await?;
600+
return user_error!(
601+
"Cannot determine a new reviewer. Use `r? <username or team>` to request a specific reviewer or a team."
602+
);
598603
}
599604
return Ok(());
600605
}

0 commit comments

Comments
 (0)