Add error handling

This commit is contained in:
Sik Yoon 2023-09-16 01:33:28 +09:00
parent a1c69ff65c
commit a484827a18

View File

@ -40,6 +40,14 @@ pub async fn market_cap_index() -> Result<(), Box<dyn std::error::Error + Send +
// JSON Parsing
let mut v: Value = serde_json::from_str(text.as_str()).unwrap();
if v
.as_object()
.unwrap()
.get("data").is_none() {
return Err("Err")?;
}
let mut into_vec = v
.as_object()
.unwrap()