From 96c0158b7acada5ade93743e1286e35eed33a3cf Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 20 Nov 2011 15:34:27 +0100 Subject: Recognized invalid place/name error messages --- lib/Travel/Status/DE/VRR.pm | 15 ++++++--- t/in/essen_hb_invalid.xml | 80 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 t/in/essen_hb_invalid.xml diff --git a/lib/Travel/Status/DE/VRR.pm b/lib/Travel/Status/DE/VRR.pm index ed97712..4617cbf 100644 --- a/lib/Travel/Status/DE/VRR.pm +++ b/lib/Travel/Status/DE/VRR.pm @@ -170,23 +170,30 @@ sub check_for_ambiguous { return; } - if ( $e_place->getAttribute('state') eq 'list' ) { + my $s_place = $e_place->getAttribute('state'); + my $s_name = $e_name->getAttribute('state'); + + if ( $s_place eq 'list' ) { $self->{errstr} = sprintf( 'Ambiguous place input: %s', join( q{ | }, map { decode( 'UTF-8', $_->textContent ) } @{ $e_place->findnodes($xp_place_elem) } ) ); - return; } - if ( $e_name->getAttribute('state') eq 'list' ) { + if ( $s_name eq 'list' ) { $self->{errstr} = sprintf( 'Ambiguous name input: %s', join( q{ | }, map { decode( 'UTF-8', $_->textContent ) } @{ $e_name->findnodes($xp_name_elem) } ) ); - return; + } + if ( $s_place eq 'notidentified' ) { + $self->{errstr} = 'invalid place parameter'; + } + if ( $s_name eq 'notidentified' ) { + $self->{errstr} = 'invalid name parameter'; } return; diff --git a/t/in/essen_hb_invalid.xml b/t/in/essen_hb_invalid.xml new file mode 100644 index 0000000..de7d10a --- /dev/null +++ b/t/in/essen_hb_invalid.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + Essen + E + + + stop invalid + Hbfoaei + Hbfoaei + + + + + + + + + + + + + + + + + + + + + + + + + + + Zug + S-Bahn + U-Bahn + Stadtbahn + Straßen-/Trambahn + Stadtbus + Regionalbus + Schnellbus + Seil-/Zahnradbahn + Schiff + AST/Rufbus + Sonstige + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3