Commit c21d47ea authored by Brad King's avatar Brad King
Browse files

gitlab: report server errors without trying to deserialize

When GitLab has a server-side error it likely has not sent a well-formed
JSON object.  Report the server error directly.
parent 918a0522
......@@ -675,7 +675,13 @@ impl Gitlab {
{
req.header(GitlabPrivateToken(self.token.to_string()));
let rsp = req.send().chain_err(|| ErrorKind::Communication)?;
let success = rsp.status().is_success();
let status = rsp.status();
if status.is_server_error() {
return Err(ErrorKind::Gitlab(
format!("server error: {} {:?}", status.as_u16(),
status.canonical_reason())).into());
}
let success = status.is_success();
let v = serde_json::from_reader(rsp).chain_err(|| ErrorKind::Deserialize)?;
if !success {
return Err(Error::from_gitlab(v));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment