Skip to content

Commit 2b47f06

Browse files
authored
Log errors at top level (#93)
1 parent d5b9478 commit 2b47f06

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

GithubCommentReader/index.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -780,17 +780,24 @@ async function handler(request, context) {
780780

781781
context.log(`Processing comment ${comment.id} on ${isPr ? "PR" : "issue"} ${issueNumber} by ${comment.user.login} (${comment.author_association})`)
782782

783-
await webhook({
784-
// The azure functions logger is a getter and crashes if passed directly
785-
log: (s) => context.log(s),
786-
issueNumber,
787-
commentId: comment.id,
788-
commentBody: comment.body,
789-
commentIsFromIssue,
790-
isPr,
791-
commentUser: comment.user.login,
792-
authorAssociation: comment.author_association,
793-
});
783+
try {
784+
await webhook({
785+
// The azure functions logger is a getter and crashes if passed directly
786+
log: (s) => context.log(s),
787+
issueNumber,
788+
commentId: comment.id,
789+
commentBody: comment.body,
790+
commentIsFromIssue,
791+
isPr,
792+
commentUser: comment.user.login,
793+
authorAssociation: comment.author_association,
794+
});
795+
} catch (e) {
796+
context.log(`Error processing comment: ${e}`);
797+
return {
798+
status: 500,
799+
};
800+
}
794801

795802
return {};
796803
}

0 commit comments

Comments
 (0)