From cdcd645dc455a0778b91b3f7d051dbfb37c8755d Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 23 Feb 2019 18:48:34 +0100 Subject: Propagate errors from api calls to caller. This defines an ApiResult type, and a corresponding Error type which wraps any errors that can be returned from underlying libs. Prevents panics due to unwraps in the core api. The main app still unwraps, and will panic on any error, though. Fix that later. --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 733af84..53752c0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,8 +21,8 @@ use oslobike; fn main() { let api_key = dotenv::var("OSLOBIKE_APIKEY").expect("No API key defined!"); - let api = oslobike::Api::new(api_key); - for station in api.stations() { + let api = oslobike::Api::new(api_key).unwrap(); + for station in api.stations().unwrap() { println!("{:>4} {}: {}", station.id, station.title, -- cgit v1.2.3