File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -24,15 +24,20 @@ impl<'a> ErrorComment<'a> {
2424 }
2525 }
2626
27- pub async fn post ( & self , client : & GithubClient ) -> anyhow:: Result < Comment > {
27+ pub fn markdown ( message : & str ) -> anyhow:: Result < String > {
2828 let mut body = String :: new ( ) ;
29- writeln ! ( body, "**Error**: {}" , self . message ) ?;
29+ writeln ! ( body, "**Error**: {message}" ) ?;
3030 writeln ! ( body) ?;
3131 writeln ! (
3232 body,
3333 "Please file an issue on GitHub at [triagebot](https://github.com/rust-lang/triagebot) if there's \
3434 a problem with this bot, or reach out on [#t-infra](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra) on Zulip."
3535 ) ?;
36+ Ok ( body)
37+ }
38+
39+ pub async fn post ( & self , client : & GithubClient ) -> anyhow:: Result < Comment > {
40+ let body = Self :: markdown ( & self . message ) ?;
3641 self . issue . post_comment ( client, & body) . await
3742 }
3843}
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ use crate::handlers::Context;
1212use crate :: handlers:: docs_update:: docs_update;
1313use crate :: handlers:: pr_tracking:: get_assigned_prs;
1414use crate :: handlers:: project_goals:: { self , ping_project_goals_owners} ;
15+ use crate :: interactions:: ErrorComment ;
1516use crate :: utils:: pluralize;
1617use crate :: zulip:: api:: { MessageApiResponse , Recipient } ;
1718use crate :: zulip:: client:: ZulipClient ;
@@ -101,7 +102,13 @@ pub async fn webhook(
101102 Ok ( req) => req,
102103 Err ( rejection) => {
103104 tracing:: error!( ?rejection) ;
104- return rejection. into_response ( ) ;
105+ return Json ( Response {
106+ content : ErrorComment :: markdown (
107+ "unable to handle this Zulip request: invalid JSON input" ,
108+ )
109+ . expect ( "creating a error message without fail" ) ,
110+ } )
111+ . into_response ( ) ;
105112 }
106113 } ;
107114
You can’t perform that action at this time.
0 commit comments