Better handling of errors, not good, but better.
This commit is contained in:
@@ -15,7 +15,7 @@ struct Error {
|
||||
pub struct Eniro;
|
||||
|
||||
impl Probe for Eniro {
|
||||
fn search(&mut self, ctx: &mut Context, number: &str) {
|
||||
fn search(&mut self, ctx: &mut Context, number: &str) -> Result<(), ()> {
|
||||
let body = if let Some(cache) = ctx.cache_get("eniro", &number) {
|
||||
String::from_utf8(cache.data).unwrap()
|
||||
} else {
|
||||
@@ -28,12 +28,13 @@ impl Probe for Eniro {
|
||||
ctx.cache_set("eniro", &number, body.as_bytes())
|
||||
.expect("wut?! why not?!");
|
||||
|
||||
println!("eniro.se:");
|
||||
|
||||
if let Ok(error) = Error::from_html(&body) {
|
||||
println!("eniro.se:");
|
||||
println!(" {}", error.message);
|
||||
|
||||
Ok(())
|
||||
} else {
|
||||
println!(" Failed to find any data");
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user