Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide more informational error strings for API #62

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/spotify/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,17 @@ pub enum ApiError {
impl failure::Fail for ApiError {}
impl fmt::Display for ApiError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Spotify API reported an error")
match self {
ApiError::Unauthorized => write!(f, "Unauthorized request to API"),
ApiError::RateLimited(e) => {
if let Some(d) = e {
write!(f, "Exceeded API request limit - please wait {} seconds", d)
} else {
write!(f, "Exceeded API request limit")
}
}
ApiError::Other(s) => write!(f, "Spotify API reported error code {}", s),
}
}
}
impl From<&reqwest::Response> for ApiError {
Expand Down