Skip to content

Commit

Permalink
Handle TimeTableResponse status error properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnau Siches committed Apr 24, 2016
1 parent 5d9bb9a commit 29d3370
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ fn transform_gtfs(lines: Vec<Line>) {
};

let id = route_section_id(&line, &route_section);
println!("\t{}, Has Timetable: {}, Duplicate: {}", id, has_timetable, route_section_ids.contains(&id));
println!(" {}, Has Timetable: {}, Duplicate: {}", id, has_timetable, route_section_ids.contains(&id));
route_section_ids.insert(id.clone());
route_section_count += 1;
}
Expand Down
11 changes: 7 additions & 4 deletions src/tfl/line.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ansi_term::Colour::{Green, Blue};
use ansi_term::Colour::{Green, Blue, Red};
use std::fmt;
use std::collections::HashSet;

Expand Down Expand Up @@ -211,6 +211,8 @@ pub struct TimeTableResponse {
pub stations: Vec<Station>,
pub stops: Vec<Station>,
pub timetable: RoutesTimeTables,
#[serde(rename="statusErrorMessage")]
pub status_error_message: Option<String>,
}

#[derive(Clone, Debug, Deserialize)]
Expand All @@ -221,10 +223,11 @@ pub struct Sequence {

impl TimeTableResponse {
pub fn first_timetable(&self) -> Option<&TimeTable> {
if self.timetable.routes.is_empty() {
Some(&self.timetable.routes[0])
} else {
if let Some(ref message) = self.status_error_message {
println!("{} {}", Red.bold().paint("Error:"), message);
None
} else {
Some(&self.timetable.routes[0])
}
}

Expand Down

0 comments on commit 29d3370

Please sign in to comment.