Improve error handling
This commit is contained in:
parent
c8adc3463e
commit
ef74def35d
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user