From a937e1a2d79a64d525eae4cebb8a39cba123f3ac Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 14 Apr 2018 23:58:46 +0200 Subject: 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. --- meetup/src/client.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'meetup/src/client.rs') 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, page: Option, - ) -> Result, Box> { + ) -> Result> { let mut params = vec![ ("key", self.token.clone()), ("lat", latitude), @@ -52,7 +51,7 @@ impl Client { } -fn parse_json(json: String) -> Result, serde_json::Error> { +fn parse_json(json: String) -> Result> { let parsed: serde_json::Value = serde_json::from_str(json.as_ref())?; let events: Vec = serde_json::from_value(parsed["events"].clone())?; -- cgit v1.2.3