Skip to content

Commit d5b87e4

Browse files
committed
Displays server response when introspection failed
1 parent a781420 commit d5b87e4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

graphql_client_cli/src/introspect_schema.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::error::Error;
12
use crate::CliResult;
23
use graphql_client::GraphQLQuery;
34
use reqwest::header::{HeaderMap, HeaderValue, ACCEPT, CONTENT_TYPE};
@@ -53,9 +54,14 @@ pub fn introspect_schema(
5354
if res.status().is_success() {
5455
// do nothing
5556
} else if res.status().is_server_error() {
56-
println!("server error!");
57+
return Err(Error::message("server error!".into()));
5758
} else {
58-
println!("Something else happened. Status: {:?}", res.status());
59+
let status = res.status();
60+
let error_message = match res.text() {
61+
Ok(msg) => format!("HTTP {}: {}", status, msg),
62+
Err(_) => format!("HTTP {}", status),
63+
};
64+
return Err(Error::message(error_message));
5965
}
6066

6167
let json: serde_json::Value = res.json()?;

0 commit comments

Comments
 (0)