github/api: return an empty list instead of crashing for issues without labels
authorAlexandre Terrasa <alexandre@moz-code.org>
Tue, 3 Feb 2015 21:24:49 +0000 (22:24 +0100)
committerAlexandre Terrasa <alexandre@moz-code.org>
Tue, 3 Feb 2015 21:24:49 +0000 (22:24 +0100)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

lib/github/api.nit

index 782d598..ba8943e 100644 (file)
@@ -678,6 +678,7 @@ class Issue
        # List of labels on this issue associated to their names.
        fun labels: Map[String, Label] do
                var res = new HashMap[String, Label]
+               if not json.has_key("labels") then return res
                for obj in json["labels"].as(JsonArray) do
                        if not obj isa JsonObject then continue
                        var name = obj["name"].to_s