Skip to content

Commit

Permalink
imp(API): improved display of BadRequest
Browse files Browse the repository at this point in the history
Previously you would only see "BadRequest ... " without the information
that would actually help you to understand what the cause of the issue
is.
Now we will print all the information we have, accordingly, which
greatly improves usability.

Closes #103
[skip ci]
  • Loading branch information
Byron committed May 9, 2015
1 parent fff466f commit e86e55c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/rust/api/cmn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,20 @@ impl Display for Error {
writeln!(f, "The application's API key was not found in the configuration").ok();
writeln!(f, "It is used as there are no Scopes defined for this method.")
},
Error::BadRequest(ref err)
=> writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message),
Error::BadRequest(ref err) => {
try!(writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message));
for err in err.error.errors.iter() {
try!(writeln!(f, " {}: {}, {}{}",
err.domain,
err.message,
err.reason,
match &err.location {
&Some(ref loc) => format!("@{}", loc),
&None => String::new(),
}));
}
Ok(())
},
Error::MissingToken(ref err) =>
writeln!(f, "Token retrieval failed with error: {}", err),
Error::Cancelled =>
Expand Down

0 comments on commit e86e55c

Please sign in to comment.