Improve error handling

This commit is contained in:
Sakuhl 2018-02-14 18:10:13 +01:00
parent c8adc3463e
commit ef74def35d

View File

@ -38,7 +38,9 @@ pub fn wc_guild(command: &str, msg: &Message) -> Result<(), Error> {
} }
let message = (|| { let message = (|| {
let resp = reqwest::get("https://api.wynncraft.com/public_api.php?action=territoryList")?.text()?; let resp = reqwest::get("https://api.wynncraft.com/public_api.php?action=territoryList")?
.error_for_status()?
.text()?;
let territories: Value = if let Ok(error) = serde_json::from_str::<APIError>(&resp) { let territories: Value = if let Ok(error) = serde_json::from_str::<APIError>(&resp) {
bail!("API error ({})", error.error); bail!("API error ({})", error.error);