diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2019-02-23 18:48:34 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2019-02-23 18:54:48 +0100 |
commit | cdcd645dc455a0778b91b3f7d051dbfb37c8755d (patch) | |
tree | 3b132d983cae541fb228235d6ee18b1280a05393 /src/main.rs | |
parent | 1b3cb7522118d711d43ca78d0c5d7e71a5afbf46 (diff) | |
download | oslobike-cdcd645dc455a0778b91b3f7d051dbfb37c8755d.tar.gz oslobike-cdcd645dc455a0778b91b3f7d051dbfb37c8755d.tar.bz2 oslobike-cdcd645dc455a0778b91b3f7d051dbfb37c8755d.zip |
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.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 4 |
1 files changed, 2 insertions, 2 deletions
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, |