Skip to content

Commit 5ca259c

Browse files
committed
fix: skip submissions that throw
1 parent 1a093d5 commit 5ca259c

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

BackgroundProcessor/Processors/RedditPostTitleFetcher.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,25 @@ public async Task Process(CancellationToken cancellationToken)
3131

3232
await foreach (var redditPostId in query)
3333
{
34-
if (!(await _submissionBrowser.GetSubmission(LinkThing.CreateFromShortId(redditPostId))).Try(out var submission))
34+
try
3535
{
36+
var submissionResult = await _submissionBrowser.GetSubmission(LinkThing.CreateFromShortId(redditPostId));
37+
38+
if (!submissionResult.Try(out var submission))
39+
{
40+
await _redditPostProvider.SetTitleFetchedForPostId(redditPostId, cancellationToken);
41+
_logger.LogInformation("Submission title couldn't be fetched for {RedditPostId} because the submission has been removed", redditPostId);
42+
return;
43+
}
44+
45+
await _redditPostProvider.SetPostTitle(redditPostId, submission.Title, cancellationToken);
46+
}
47+
catch (Exception ex)
48+
{
49+
// We'll figure out how to clean these up later
50+
_logger.LogError(ex, "Error fetching title for {RedditPostId}", redditPostId);
3651
await _redditPostProvider.SetTitleFetchedForPostId(redditPostId, cancellationToken);
37-
_logger.LogInformation("Submission title couldn't be fetched for {RedditPostId} because the submission has been removed", redditPostId);
38-
return;
3952
}
40-
41-
await _redditPostProvider.SetPostTitle(redditPostId, submission.Title, cancellationToken);
4253
}
4354
}
4455
}

0 commit comments

Comments
 (0)