Skip to content

Commit 33cb57e

Browse files
authored
Merge pull request #2178 from Urgau/err-handler-context
Add handler name as context for errors coming from GitHub handlers
2 parents 5cbdfd5 + f4257bd commit 33cb57e

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/handlers.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,14 @@ macro_rules! issue_handlers {
222222
Err(err) => Err(HandlerError::Message(err)),
223223
Ok(Some(input)) => {
224224
if let Some(config) = &config.$name {
225-
$name::handle_input(ctx, config, event, input).await.map_err(HandlerError::Other)
225+
$name::handle_input(ctx, config, event, input)
226+
.await
227+
.map_err(|e| {
228+
HandlerError::Other(e.context(format!(
229+
"error when processing {} handler",
230+
stringify!($name)
231+
)))
232+
})
226233
} else {
227234
Err(HandlerError::Message(format!(
228235
"The feature `{}` is not enabled in this repository.\n\
@@ -361,7 +368,12 @@ macro_rules! command_handlers {
361368
if let Some(config) = &config.$name {
362369
$name::handle_command(ctx, config, event, command)
363370
.await
364-
.unwrap_or_else(|err| errors.push(HandlerError::Other(err)));
371+
.unwrap_or_else(|err| {
372+
errors.push(HandlerError::Other(err.context(format!(
373+
"error when processing {} command handler",
374+
stringify!($name)
375+
))))
376+
});
365377
} else {
366378
errors.push(HandlerError::Message(format!(
367379
"The feature `{}` is not enabled in this repository.\n\

0 commit comments

Comments
 (0)