Skip to content

Commit b974865

Browse files
committed
Ignore parse errors on broken GitHub API endpoint
Related to #153.
1 parent 7889e9e commit b974865

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/statistics.zig

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ const Repository = struct {
5656
);
5757
defer client.allocator.free(response.body);
5858
if (response.status == .ok) {
59-
const authors = (try std.json.parseFromSliceLeaky(
59+
self.lines_changed = 0;
60+
const authors = std.json.parseFromSliceLeaky(
6061
[]struct {
6162
author: struct { login: []const u8 },
6263
weeks: []struct {
@@ -67,8 +68,16 @@ const Repository = struct {
6768
arena.allocator(),
6869
response.body,
6970
.{ .ignore_unknown_fields = true },
70-
));
71-
self.lines_changed = 0;
71+
) catch {
72+
// TODO: Replace with proper exception propagation when GitHub
73+
// gets their shit together and stops breaking this endpoint
74+
std.log.info(
75+
"Skipping lines changed by {s} in {s} due to invalid " ++
76+
"response from GitHub.",
77+
.{ user, self.name },
78+
);
79+
return response.status;
80+
};
7281
for (authors) |o| {
7382
if (!std.mem.eql(u8, o.author.login, user)) {
7483
continue;

0 commit comments

Comments
 (0)