From: Alexandre Terrasa Date: Sat, 28 Nov 2015 21:50:46 +0000 (-0500) Subject: github/api: avoid crashes with unparsable responses X-Git-Tag: v0.8~69^2 X-Git-Url: http://nitlanguage.org github/api: avoid crashes with unparsable responses Signed-off-by: Alexandre Terrasa --- diff --git a/lib/github/api.nit b/lib/github/api.nit index 7e7400c..91cc006 100644 --- a/lib/github/api.nit +++ b/lib/github/api.nit @@ -814,10 +814,16 @@ class Issue for obj in array do if not obj isa JsonObject then continue var id = obj["id"].as(Int) - res.add(api.load_issue_comment(repo, id).as(not null)) + var comment = api.load_issue_comment(repo, id) + if comment == null then continue + res.add(comment) end page += 1 - array = api.get("{key}/comments?page={page}").as(JsonArray) + var json = api.get("{key}/comments?page={page}") + if not json isa JsonArray then + return res + end + array = json end return res end