aboutsummaryrefslogtreecommitdiffstats
path: root/meetup/src/client.rs
diff options
context:
space:
mode:
authorTeddy Wing2018-04-14 23:58:46 +0200
committerTeddy Wing2018-04-15 00:00:39 +0200
commita937e1a2d79a64d525eae4cebb8a39cba123f3ac (patch)
tree5cc4e40def66fc6eb8bbfe418605d81dc0ce11a2 /meetup/src/client.rs
parente1dbf0ad02178f265f50ea9aa7e460cfcf88c406 (diff)
downloadmeetup-find-events-rss-a937e1a2d79a64d525eae4cebb8a39cba123f3ac.tar.bz2
meetup: Handle errors with 'error-chain'
Use this instead of `Box`es. Hoping this, along with using the library in my main crate also, will help me get some more context on my runtime error. Hey, it did! Turns out the error is coming from 'serde_json'. Cool.
Diffstat (limited to 'meetup/src/client.rs')
-rw-r--r--meetup/src/client.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/meetup/src/client.rs b/meetup/src/client.rs
index 6f98a1f..5e8e636 100644
--- a/meetup/src/client.rs
+++ b/meetup/src/client.rs
@@ -1,8 +1,7 @@
use reqwest;
use serde_json;
-use std::error::Error;
-
+use errors::*;
use event::Event;
const MEETUP_BASE_URL: &'static str = "https://api.meetup.com";
@@ -23,7 +22,7 @@ impl Client {
end_date_range: String,
radius: Option<String>,
page: Option<String>,
- ) -> Result<Vec<Event>, Box<Error>> {
+ ) -> Result<Vec<Event>> {
let mut params = vec![
("key", self.token.clone()),
("lat", latitude),
@@ -52,7 +51,7 @@ impl Client {
}
-fn parse_json(json: String) -> Result<Vec<Event>, serde_json::Error> {
+fn parse_json(json: String) -> Result<Vec<Event>> {
let parsed: serde_json::Value = serde_json::from_str(json.as_ref())?;
let events: Vec<Event> = serde_json::from_value(parsed["events"].clone())?;