Skip to content

Commit 0e33081

Browse files
committed
Pretty JSON error responses
1 parent d5b87e4 commit 0e33081

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

graphql_client_cli/src/introspect_schema.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ pub fn introspect_schema(
5858
} else {
5959
let status = res.status();
6060
let error_message = match res.text() {
61-
Ok(msg) => format!("HTTP {}: {}", status, msg),
61+
Ok(msg) => match serde_json::from_str::<serde_json::Value>(&msg) {
62+
Ok(json) => format!("HTTP {}\n{}", status, serde_json::to_string_pretty(&json)?),
63+
Err(_) => format!("HTTP {}: {}", status, msg),
64+
},
6265
Err(_) => format!("HTTP {}", status),
6366
};
6467
return Err(Error::message(error_message));

0 commit comments

Comments
 (0)