nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
tests: add some runtime error in nitin.input
[nit.git]
/
lib
/
github
/
github_curl.nit
diff --git
a/lib/github/github_curl.nit
b/lib/github/github_curl.nit
index
a15d439
..
026456c
100644
(file)
--- a/
lib/github/github_curl.nit
+++ b/
lib/github/github_curl.nit
@@
-18,6
+18,7
@@
module github_curl
import curl
import json::static
import curl
import json::static
+import json
# Specific Curl that know hot to talk to the github API
class GithubCurl
# Specific Curl that know hot to talk to the github API
class GithubCurl
@@
-52,7
+53,7
@@
class GithubCurl
if response isa CurlResponseSuccess then
var obj = response.body_str.parse_json
if obj isa JsonObject then
if response isa CurlResponseSuccess then
var obj = response.body_str.parse_json
if obj isa JsonObject then
- if obj.keys.has("message") then
+ if obj.keys.has("message") and obj.keys.has("documentation_url") then
print "Message from Github API: {obj["message"] or else ""}"
print "Requested URI: {uri}"
abort
print "Message from Github API: {obj["message"] or else ""}"
print "Requested URI: {uri}"
abort
@@
-82,9
+83,9
@@
class GithubCurl
if response isa CurlResponseSuccess then
var obj = response.body_str.parse_json
if obj isa JsonObject then
if response isa CurlResponseSuccess then
var obj = response.body_str.parse_json
if obj isa JsonObject then
- if obj.keys.has("message") then
+ if obj.keys.has("message") and obj.keys.has("documentation_url") then
var title = "GithubAPIError"
var title = "GithubAPIError"
- var msg = obj["message"].to_s
+ var msg = obj["message"].as(not null).to_s
var err = new GithubError(msg, title)
err.json["requested_uri"] = uri
err.json["status_code"] = response.status_code
var err = new GithubError(msg, title)
err.json["requested_uri"] = uri
err.json["status_code"] = response.status_code
@@
-127,9
+128,7
@@
class GithubError
json["message"] = message.to_json
end
json["message"] = message.to_json
end
- redef fun to_json do
- return json.to_json
- end
+ redef fun serialize_to(v) do json.serialize_to v
redef fun to_s do return "[{name}] {super}"
end
redef fun to_s do return "[{name}] {super}"
end