@@ -84,130 +84,168 @@ pub async fn handle(ctx: &Context, host: &str, event: &Event) -> Vec<HandlerErro
84
84
handle_command ( ctx, event, & config, body, & mut errors) . await ;
85
85
}
86
86
87
- if let Ok ( config ) = & config {
88
- if let Err ( e ) = check_commits :: handle ( ctx , host , event , & config) . await {
89
- log :: error! (
90
- "failed to process event {:?} with `check_commits` handler: {:?}" ,
91
- event ,
92
- e
93
- ) ;
87
+ let check_commits = async {
88
+ if let Ok ( check_commits_config ) = & config {
89
+ check_commits :: handle ( ctx , host , event , check_commits_config )
90
+ . await
91
+ . map_err ( |e| HandlerError :: Other ( e . context ( "check_commits handler failed" ) ) )
92
+ } else {
93
+ Ok ( ( ) )
94
94
}
95
- }
95
+ } ;
96
96
97
- if let Err ( e) = project_goals:: handle ( ctx, event) . await {
98
- log:: error!(
99
- "failed to process event {:?} with `project_goals` handler: {:?}" ,
100
- event,
101
- e
102
- ) ;
103
- }
97
+ let project_goals = async {
98
+ project_goals:: handle ( ctx, event)
99
+ . await
100
+ . map_err ( |e| HandlerError :: Other ( e. context ( "project_goals handler failed" ) ) )
101
+ } ;
104
102
105
- if let Err ( e) = notification:: handle ( ctx, event) . await {
106
- log:: error!(
107
- "failed to process event {:?} with notification handler: {:?}" ,
108
- event,
109
- e
110
- ) ;
111
- }
103
+ let notification = async {
104
+ notification:: handle ( ctx, event)
105
+ . await
106
+ . map_err ( |e| HandlerError :: Other ( e. context ( "notification handler failed" ) ) )
107
+ } ;
112
108
113
- if let Err ( e) = rustc_commits:: handle ( ctx, event) . await {
114
- log:: error!(
115
- "failed to process event {:?} with rustc_commits handler: {:?}" ,
116
- event,
117
- e
118
- ) ;
119
- }
109
+ let rustc_commits = async {
110
+ rustc_commits:: handle ( ctx, event)
111
+ . await
112
+ . map_err ( |e| HandlerError :: Other ( e. context ( "rustc_commits handler failed" ) ) )
113
+ } ;
120
114
121
- if let Err ( e) = milestone_prs:: handle ( ctx, event) . await {
122
- log:: error!(
123
- "failed to process event {:?} with milestone_prs handler: {:?}" ,
124
- event,
125
- e
126
- ) ;
127
- }
115
+ let milestone_prs = async {
116
+ milestone_prs:: handle ( ctx, event)
117
+ . await
118
+ . map_err ( |e| HandlerError :: Other ( e. context ( "milestone_prs handler failed" ) ) )
119
+ } ;
128
120
129
- if let Some ( rendered_link_config) = config. as_ref ( ) . ok ( ) . and_then ( |c| c. rendered_link . as_ref ( ) )
130
- {
131
- if let Err ( e) = rendered_link:: handle ( ctx, event, rendered_link_config) . await {
132
- log:: error!(
133
- "failed to process event {:?} with rendered_link handler: {:?}" ,
134
- event,
135
- e
136
- ) ;
121
+ let rendered_link = async {
122
+ if let Some ( rendered_link_config) =
123
+ config. as_ref ( ) . ok ( ) . and_then ( |c| c. rendered_link . as_ref ( ) )
124
+ {
125
+ rendered_link:: handle ( ctx, event, rendered_link_config)
126
+ . await
127
+ . map_err ( |e| HandlerError :: Other ( e. context ( "rendered_link handler failed" ) ) )
128
+ } else {
129
+ Ok ( ( ) )
137
130
}
138
- }
131
+ } ;
139
132
140
- if let Err ( e) = relnotes:: handle ( ctx, event) . await {
141
- log:: error!(
142
- "failed to process event {:?} with relnotes handler: {:?}" ,
143
- event,
144
- e
145
- ) ;
146
- }
133
+ let relnotes = async {
134
+ relnotes:: handle ( ctx, event)
135
+ . await
136
+ . map_err ( |e| HandlerError :: Other ( e. context ( "relnotes handler failed" ) ) )
137
+ } ;
147
138
148
- if config . as_ref ( ) . is_ok_and ( |c| c . bot_pull_requests . is_some ( ) ) {
149
- if let Err ( e ) = bot_pull_requests:: handle ( ctx , event ) . await {
150
- log :: error! (
151
- "failed to process event {:?} with bot_pull_requests handler: {:?}" ,
152
- event ,
153
- e
154
- )
139
+ let bot_pull_requests = async {
140
+ if config . as_ref ( ) . is_ok_and ( |c| c . bot_pull_requests . is_some ( ) ) {
141
+ bot_pull_requests :: handle ( ctx , event )
142
+ . await
143
+ . map_err ( |e| HandlerError :: Other ( e . context ( "bot_pull_requests handler failed" ) ) )
144
+ } else {
145
+ Ok ( ( ) )
155
146
}
156
- }
147
+ } ;
157
148
158
- if let Some ( config ) = config
159
- . as_ref ( )
160
- . ok ( )
161
- . and_then ( |c| c . review_submitted . as_ref ( ) )
162
- {
163
- if let Err ( e ) = review_submitted :: handle ( ctx , event , config ) . await {
164
- log :: error! (
165
- "failed to process event {:?} with review_submitted handler: {:?}" ,
166
- event ,
167
- e
168
- )
149
+ let review_submitted = async {
150
+ if let Some ( review_submitted_config ) = config
151
+ . as_ref ( )
152
+ . ok ( )
153
+ . and_then ( |c| c . review_submitted . as_ref ( ) )
154
+ {
155
+ review_submitted :: handle ( ctx , event , review_submitted_config )
156
+ . await
157
+ . map_err ( |e| HandlerError :: Other ( e . context ( "review_submitted handler failed" ) ) )
158
+ } else {
159
+ Ok ( ( ) )
169
160
}
170
- }
161
+ } ;
171
162
172
- if let Some ( config ) = config
173
- . as_ref ( )
174
- . ok ( )
175
- . and_then ( |c| c . review_changes_since . as_ref ( ) )
176
- {
177
- if let Err ( e ) = review_changes_since :: handle ( ctx , host , event , config ) . await {
178
- log :: error! (
179
- "failed to process event {:?} with review_changes_since handler: {:?}" ,
180
- event ,
181
- e
182
- )
163
+ let review_changes_since = async {
164
+ if let Some ( review_changes_since_config ) = config
165
+ . as_ref ( )
166
+ . ok ( )
167
+ . and_then ( |c| c . review_changes_since . as_ref ( ) )
168
+ {
169
+ review_changes_since :: handle ( ctx , host , event , review_changes_since_config )
170
+ . await
171
+ . map_err ( |e| HandlerError :: Other ( e . context ( "review_changes_since handler failed" ) ) )
172
+ } else {
173
+ Ok ( ( ) )
183
174
}
184
- }
175
+ } ;
185
176
186
- if let Some ( ghr_config ) = config
187
- . as_ref ( )
188
- . ok ( )
189
- . and_then ( |c| c . github_releases . as_ref ( ) )
190
- {
191
- if let Err ( e ) = github_releases :: handle ( ctx , event , ghr_config ) . await {
192
- log :: error! (
193
- "failed to process event {:?} with github_releases handler: {:?}" ,
194
- event ,
195
- e
196
- ) ;
177
+ let github_releases = async {
178
+ if let Some ( github_releases_config ) = config
179
+ . as_ref ( )
180
+ . ok ( )
181
+ . and_then ( |c| c . github_releases . as_ref ( ) )
182
+ {
183
+ github_releases :: handle ( ctx , event , github_releases_config )
184
+ . await
185
+ . map_err ( |e| HandlerError :: Other ( e . context ( "github_releases handler failed" ) ) )
186
+ } else {
187
+ Ok ( ( ) )
197
188
}
198
- }
189
+ } ;
199
190
200
- if let Some ( conflict_config) = config
201
- . as_ref ( )
202
- . ok ( )
203
- . and_then ( |c| c. merge_conflicts . as_ref ( ) )
204
- {
205
- if let Err ( e) = merge_conflicts:: handle ( ctx, event, conflict_config) . await {
206
- log:: error!(
207
- "failed to process event {:?} with merge_conflicts handler: {:?}" ,
208
- event,
209
- e
210
- ) ;
191
+ let merge_conflicts = async {
192
+ if let Some ( merge_conflicts_config) = config
193
+ . as_ref ( )
194
+ . ok ( )
195
+ . and_then ( |c| c. merge_conflicts . as_ref ( ) )
196
+ {
197
+ merge_conflicts:: handle ( ctx, event, merge_conflicts_config)
198
+ . await
199
+ . map_err ( |e| HandlerError :: Other ( e. context ( "merge_conflicts handler failed" ) ) )
200
+ } else {
201
+ Ok ( ( ) )
202
+ }
203
+ } ;
204
+
205
+ let (
206
+ check_commits,
207
+ project_goals,
208
+ notification,
209
+ rustc_commits,
210
+ milestone_prs,
211
+ rendered_link,
212
+ relnotes,
213
+ bot_pull_requests,
214
+ review_submitted,
215
+ review_changes_since,
216
+ github_releases,
217
+ merge_conflicts,
218
+ ) = futures:: join!(
219
+ check_commits,
220
+ project_goals,
221
+ notification,
222
+ rustc_commits,
223
+ milestone_prs,
224
+ rendered_link,
225
+ relnotes,
226
+ bot_pull_requests,
227
+ review_submitted,
228
+ review_changes_since,
229
+ github_releases,
230
+ merge_conflicts,
231
+ ) ;
232
+
233
+ for result in [
234
+ check_commits,
235
+ project_goals,
236
+ notification,
237
+ rustc_commits,
238
+ milestone_prs,
239
+ rendered_link,
240
+ relnotes,
241
+ bot_pull_requests,
242
+ review_submitted,
243
+ review_changes_since,
244
+ github_releases,
245
+ merge_conflicts,
246
+ ] {
247
+ if let Err ( e) = result {
248
+ errors. push ( e) ;
211
249
}
212
250
}
213
251
0 commit comments