fix: Check the response object before trying to extract a dns record id from it

This commit is contained in:
Rostislav Raykov 2019-09-23 10:58:04 +02:00
parent 403ec58e21
commit b654f4523e

View file

@ -77,7 +77,16 @@ pub fn get_dns_record_id(
return Err(format_err!("API Error: {}", err));
}
Ok(response.result[0].id.clone())
let id = match response.result.first() {
Some(v) => v.id.clone(),
None => {
return Err(format_err!(
"Unexpected API result for DNS record. Check if you passed the right options."
))
}
};
Ok(id)
}
pub fn get_current_ip() -> Result<String, Error> {