Skip to content

Commit

Permalink
fix NRE when OrderedItems is null (and log it, I'm curious) (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
g3rv4 authored Feb 9, 2023
1 parent 91ac0e2 commit 6fd7804
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,19 @@ await Parallel.ForEachAsync(Config.Instance.Sites,
return;
}

int count = 0;
foreach (var statusLink in data.OrderedItems.Where(i=>!imported.Contains(i)))
if (data.OrderedItems == null)
{
Console.WriteLine($"Got null on OrderedItems when pulling #{tag} posts from {site}");
return;
}

var count = 0;
foreach (var statusLink in data.OrderedItems.Where(i => !imported.Contains(i)))
{
statusesToLoadBag.Add(statusLink);
count++;
}

Console.WriteLine($"Retrieved {count} new statuses from {site} with hashtag #{tag}");
});

Expand Down Expand Up @@ -164,7 +170,7 @@ await Parallel.ForEachAsync(Config.Instance.Sites,

public class TagResponse
{
public string[] OrderedItems { get; }
public string[]? OrderedItems { get; }

public TagResponse(string[] orderedItems)
{
Expand Down

0 comments on commit 6fd7804

Please sign in to comment.