Skip to content

Commit 342b01b

Browse files
committed
Add basic error handling to GraphQL query
Fixes #123
1 parent a51ce4e commit 342b01b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,19 @@ fn get_issues_by_milestone(version: &str, repo_name: &'static str) -> Vec<json::
163163

164164
let client = Client::new();
165165

166-
let json = client
166+
let response = client
167167
.post("https://api.github.com/graphql")
168168
.headers(headers.clone())
169169
.body(json_query)
170170
.send()
171-
.unwrap()
171+
.unwrap();
172+
let status = response.status();
173+
let json = response
172174
.json::<json::Value>()
173175
.unwrap();
176+
if !status.is_success() {
177+
panic!("API Error {}: {}", status, json);
178+
}
174179

175180
let milestones_data = json["data"]["repository"]["milestones"].clone();
176181
assert_eq!(

0 commit comments

Comments
 (0)