Skip to content

Commit c7071c1

Browse files
authored
Merge pull request #1187 from webstech/comment
mail archive - catch comment errors
2 parents b728d73 + c1607ad commit c7071c1

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

lib/mail-archive-helper.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,25 +202,31 @@ export class MailArchiveGitHelper {
202202
(parsedMbox.from ?
203203
parsedMbox.from.replace(/ *<.*>/, "") : "Somebody") +
204204
` wrote ([reply to this](${replyToThisURL})):\n\n`;
205-
const comment = header +
206-
MailArchiveGitHelper.mbox2markdown(parsedMbox);
205+
const comment = MailArchiveGitHelper.mbox2markdown(parsedMbox);
206+
const fullComment = header + comment;
207207

208208
if (issueCommentId) {
209209
await this.githubGlue.addPRCommentReply(pullRequestURL,
210210
issueCommentId,
211-
comment);
211+
fullComment);
212212
} else if (originalCommit) {
213-
const result = await this.githubGlue
214-
.addPRCommitComment(pullRequestURL, originalCommit,
215-
this.gggNotes.workDir, comment);
216-
issueCommentId = result.id;
213+
try {
214+
const result = await this.githubGlue
215+
.addPRCommitComment(pullRequestURL, originalCommit,
216+
this.gggNotes.workDir, fullComment);
217+
issueCommentId = result.id;
218+
} catch (error) {
219+
const regarding = `${header.slice(0,-3)}, regarding ${originalCommit}:\n\n`;
220+
await this.githubGlue.addPRComment(pullRequestURL, regarding + comment);
221+
originalCommit = undefined;
222+
}
217223
} else {
218224
/*
219225
* We will not use the ID of this comment, as it is an
220226
* issue comment, really, not a Pull Request comment.
221227
*/
222228
await this.githubGlue
223-
.addPRComment(pullRequestURL, comment);
229+
.addPRComment(pullRequestURL, fullComment);
224230
}
225231

226232
await this.githubGlue.addPRCc(pullRequestURL,

0 commit comments

Comments
 (0)