Skip to content

Commit 1cdce75

Browse files
authored
Merge pull request #2107 from Urgau/concerns-logs
Add more logs to the concerns handler
2 parents 96f973d + 6b17396 commit 1cdce75

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/handlers/concern.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ pub(super) async fn handle_command(
7373
issue_comment.comment.author_association,
7474
AuthorAssociation::Member | AuthorAssociation::Owner
7575
) {
76+
tracing::info!(
77+
"{}#{} tried to register a concern, but author association isn't right: {:?}",
78+
issue_comment.repository.full_name,
79+
issue.number,
80+
issue_comment.comment.author_association,
81+
);
7682
issue
7783
.post_comment(
7884
&ctx.github,
@@ -84,7 +90,9 @@ pub(super) async fn handle_command(
8490

8591
let mut client = ctx.db.get().await;
8692
let mut edit: EditIssueBody<'_, ConcernData> =
87-
EditIssueBody::load(&mut client, &issue, CONCERN_ISSUE_KEY).await?;
93+
EditIssueBody::load(&mut client, &issue, CONCERN_ISSUE_KEY)
94+
.await
95+
.context("unable to fetch the concerns data")?;
8896
let concern_data = edit.data_mut();
8997

9098
// Process the command by either adding a new concern or resolving the old one
@@ -97,6 +105,11 @@ pub(super) async fn handle_command(
97105
status: ConcernStatus::Active,
98106
comment_url: comment_url.to_string(),
99107
});
108+
} else {
109+
tracing::info!(
110+
"concern with the same name ({title}) already exists ({:?})",
111+
&concern_data.concerns
112+
);
100113
}
101114
}
102115
ConcernCommand::Resolve { title } => concern_data
@@ -137,11 +150,14 @@ pub(super) async fn handle_command(
137150
issue.post_comment(
138151
&ctx.github,
139152
&format!("*Psst, I was unable to add the labels ({labels}), could someone do it for me.*"),
140-
).await?;
153+
).await.context("unable to post the comment failure it-self")?;
141154
}
142155
} else {
143156
for l in &config.labels {
144-
issue.remove_label(&ctx.github, &l).await?;
157+
issue
158+
.remove_label(&ctx.github, &l)
159+
.await
160+
.context("unable to remove the concern labels")?;
145161
}
146162
}
147163

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ pub async fn webhook(
255255
if let Some(issue) = event.issue() {
256256
let cmnt = ErrorComment::new(issue, message);
257257
cmnt.post(&ctx.github).await?;
258+
} else {
259+
log::error!("handling event failed: {:?}", message);
258260
}
259261
}
260262
if other_error {

0 commit comments

Comments
 (0)