Skip to content

Commit

Permalink
fix: Add Error Message
Browse files Browse the repository at this point in the history
  • Loading branch information
Pylogmon committed Sep 25, 2023
1 parent b60cefc commit 9e6120f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ pub fn collection(
return Ok(Value::Bool(true));
} else {
if let Some(msg) = json.get("msg") {
return Ok(Value::String(msg.as_str().unwrap().to_string()));
return Err(msg.as_str().unwrap().into());
}
}
}
}
Ok(Value::Bool(false))
Err("Unknown Error".into())
}

#[cfg(test)]
Expand All @@ -43,7 +43,7 @@ mod tests {
fn try_request() {
let mut needs = HashMap::new();
needs.insert("cookie".to_string(), "".to_string());
let result = collection("Hello", "", "en", "zh", needs).unwrap();
println!("{result}");
let result = collection("Hello", "", "en", "zh", needs);
println!("{result:?}");
}
}

0 comments on commit 9e6120f

Please sign in to comment.