aboutsummaryrefslogtreecommitdiff
path: root/src/tw/mod.rs
diff options
context:
space:
mode:
authorAndy Wortman <ixineeringeverywhere@gmail.com>2017-10-27 01:23:05 -0700
committerAndy Wortman <ixineeringeverywhere@gmail.com>2017-10-27 01:23:05 -0700
commitbf7f5d32a7f05bb0a7bc19dcb443d3df439243ba (patch)
treef3123c3678085ca6bb9a679272e02efe0e427fff /src/tw/mod.rs
parentccccc6e1b2ebd62a35715f71c746f3a3b9c0b97e (diff)
better error handling in cases where event json changes
Diffstat (limited to 'src/tw/mod.rs')
-rw-r--r--src/tw/mod.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/tw/mod.rs b/src/tw/mod.rs
index 5f40c5e..d0bad59 100644
--- a/src/tw/mod.rs
+++ b/src/tw/mod.rs
@@ -257,7 +257,6 @@ fn parse_word_command<'a, 'b>(line: &'b str, commands: &[&'a Command]) -> Option
}
} else if line.starts_with(cmd.keyword) {
if line.find(" ").map(|x| x == cmd.keyword.len()).unwrap_or(false) {
- // let inner_twid = u64::from_str(&linestr.split(" ").collect::<Vec<&str>>()[1]).unwrap();
return Some((line.get((cmd.keyword.len() + 1)..).unwrap().trim(), &cmd));
}
}
@@ -641,10 +640,13 @@ fn handle_twitter_event(
tweeter: &mut TwitterCache,
mut queryer: &mut ::Queryer) {
tweeter.cache_api_event(structure.clone(), &mut queryer);
- if let Some(event) = events::Event::from_json(structure) {
- tweeter.display_info.recv(display::Infos::Event(event));
- } else {
- // ought to handle the None case...
+ match events::Event::from_json(structure) {
+ Ok(event) => {
+ tweeter.display_info.recv(display::Infos::Event(event));
+ },
+ Err(e) => {
+ tweeter.display_info.status(format!("Unknown twitter json: {:?}", e));
+ }
}
}