Add error handling
This commit is contained in:
parent
13f9848f88
commit
3dd3dfc344
|
|
@ -465,6 +465,15 @@ pub async fn market_cap_index() -> Result<(), Box<dyn std::error::Error + Send +
|
|||
let elem = driver.find_element(By::Tag("pre")).await?;
|
||||
let text = elem.text().await?;
|
||||
v = serde_json::from_str(text.as_str()).unwrap();
|
||||
|
||||
if v.as_object().is_none() {
|
||||
return Err("Err")?;
|
||||
}
|
||||
|
||||
if v.as_object().unwrap().get("data").is_none() {
|
||||
return Err("Err")?;
|
||||
}
|
||||
|
||||
into_vec = v
|
||||
.as_object()
|
||||
.unwrap()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user