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> {
24
24
}
25
25
}
26
26
27
- pub async fn post ( & self , client : & GithubClient ) -> anyhow:: Result < Comment > {
27
+ pub fn markdown ( message : & str ) -> anyhow:: Result < String > {
28
28
let mut body = String :: new ( ) ;
29
- writeln ! ( body, "**Error**: {}" , self . message ) ?;
29
+ writeln ! ( body, "**Error**: {message}" ) ?;
30
30
writeln ! ( body) ?;
31
31
writeln ! (
32
32
body,
33
33
"Please file an issue on GitHub at [triagebot](https://github.com/rust-lang/triagebot) if there's \
34
34
a problem with this bot, or reach out on [#t-infra](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra) on Zulip."
35
35
) ?;
36
+ Ok ( body)
37
+ }
38
+
39
+ pub async fn post ( & self , client : & GithubClient ) -> anyhow:: Result < Comment > {
40
+ let body = Self :: markdown ( & self . message ) ?;
36
41
self . issue . post_comment ( client, & body) . await
37
42
}
38
43
}
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ use crate::handlers::Context;
12
12
use crate :: handlers:: docs_update:: docs_update;
13
13
use crate :: handlers:: pr_tracking:: get_assigned_prs;
14
14
use crate :: handlers:: project_goals:: { self , ping_project_goals_owners} ;
15
+ use crate :: interactions:: ErrorComment ;
15
16
use crate :: utils:: pluralize;
16
17
use crate :: zulip:: api:: { MessageApiResponse , Recipient } ;
17
18
use crate :: zulip:: client:: ZulipClient ;
@@ -101,7 +102,13 @@ pub async fn webhook(
101
102
Ok ( req) => req,
102
103
Err ( rejection) => {
103
104
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 ( ) ;
105
112
}
106
113
} ;
107
114
You can’t perform that action at this time.
0 commit comments