From 96425724b0e435c33876f4dd9685aed2bbdea1fd Mon Sep 17 00:00:00 2001 From: iximeow Date: Wed, 1 Nov 2017 04:31:43 -0700 Subject: move more logging to be through DisplayInfo statuses move DisplayInfo into ... display flush output, duh --- src/tw/events.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/tw/events.rs') diff --git a/src/tw/events.rs b/src/tw/events.rs index 35167a3..0da27a1 100644 --- a/src/tw/events.rs +++ b/src/tw/events.rs @@ -22,11 +22,13 @@ impl Event { fn get_source_target_ids(structure: serde_json::Map) -> Result<(String, String), String> { match ( structure.get("source").and_then(|x| x.get("id_str").and_then(|x| x.as_str())), - structure.get("target_obj").and_then(|x| x.get("id_str").and_then(|x| x.as_str())) + structure.get("target_object").and_then(|x| x.get("id_str").and_then(|x| x.as_str())) ) { (Some(source_id), Some(target_id)) => Ok((source_id.to_string(), target_id.to_string())), - (None, Some(target_id)) => Err("No id_str string at .source.id_str".to_string()), - (Some(target_id), None) => Err("No id_str string at .target_object.id_str".to_string()), + // have more particular error types for "missing fields", "missing data", "invalid + // state", etc, so downstream we can opt to investigate the bad data or not.. + (None, Some(_)) => Err("No id_str string at .source.id_str: {}".to_string()), + (Some(_), None) => Err("No id_str string at .target_object.id_str: {}".to_string()), (None, None) => Err("No id_str at source or target_object".to_string()) } } @@ -96,7 +98,7 @@ impl Event { // what about removed? // "blocked" => Blocked { }, // "unblocked" => Unblocked { }, - e => { println!("unrecognized event: {}", e); Err(e.to_string()) } + e => Err(e.to_string()) } }, None => { -- cgit v1.1