diff --git a/src/handlers/check_commits.rs b/src/handlers/check_commits.rs index 678234a3..f7f173dc 100644 --- a/src/handlers/check_commits.rs +++ b/src/handlers/check_commits.rs @@ -4,6 +4,7 @@ use anyhow::Context as _; use anyhow::bail; use super::Context; +use crate::interactions::ErrorComment; use crate::{ config::Config, db::issue_data::IssueData, @@ -157,7 +158,8 @@ async fn handle_new_state( } for error_to_add in errors_to_add { - let comment = event.issue.post_comment(&ctx.github, &error_to_add).await?; + let error_comment = ErrorComment::new(&event.issue, &error_to_add); + let comment = error_comment.post(&ctx.github).await?; state.data.last_errors.push((error_to_add, comment.node_id)); } } diff --git a/src/interactions.rs b/src/interactions.rs index e0b38bb5..0f98a113 100644 --- a/src/interactions.rs +++ b/src/interactions.rs @@ -4,7 +4,7 @@ use tokio_postgres::Client as DbClient; use crate::{ db::issue_data::IssueData, - github::{GithubClient, Issue}, + github::{Comment, GithubClient, Issue}, }; use std::fmt::Write; @@ -24,7 +24,7 @@ impl<'a> ErrorComment<'a> { } } - pub async fn post(&self, client: &GithubClient) -> anyhow::Result<()> { + pub async fn post(&self, client: &GithubClient) -> anyhow::Result { let mut body = String::new(); writeln!(body, "**Error**: {}", self.message)?; writeln!(body)?; @@ -33,8 +33,7 @@ impl<'a> ErrorComment<'a> { "Please file an issue on GitHub at [triagebot](https://github.com/rust-lang/triagebot) if there's \ a problem with this bot, or reach out on [#t-infra](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra) on Zulip." )?; - self.issue.post_comment(client, &body).await?; - Ok(()) + self.issue.post_comment(client, &body).await } }