summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2016-03-06 11:56:50 +0100
committerDaniel Friesel <derf@finalrewind.org>2016-03-06 11:56:50 +0100
commita38c78f282cbccf0756040413914f024868e8c51 (patch)
treeda58cd79dae985bbd78e8a9b4baa4029f7b976af
parent4e1fefca3e826b27ab3e4e32bc38115653aa14d1 (diff)
EFA: Don't crash when calling ->identified_data or ->lines without XML
-rw-r--r--lib/Travel/Status/DE/EFA.pm24
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/Travel/Status/DE/EFA.pm b/lib/Travel/Status/DE/EFA.pm
index c9123df..0c2d1b2 100644
--- a/lib/Travel/Status/DE/EFA.pm
+++ b/lib/Travel/Status/DE/EFA.pm
@@ -271,6 +271,10 @@ sub check_for_ambiguous {
sub identified_data {
my ($self) = @_;
+ if ( not $self->{tree} ) {
+ return;
+ }
+
my $xp_place
= XML::LibXML::XPathExpression->new('//itdOdv/itdOdvPlace/odvPlaceElem');
my $xp_name
@@ -286,6 +290,14 @@ sub lines {
my ($self) = @_;
my @lines;
+ if ( $self->{lines} ) {
+ return @{ $self->{lines} };
+ }
+
+ if ( not $self->{tree} ) {
+ return;
+ }
+
my $xp_element
= XML::LibXML::XPathExpression->new('//itdServingLines/itdServingLine');
@@ -293,10 +305,6 @@ sub lines {
my $xp_route = XML::LibXML::XPathExpression->new('./itdRouteDescText');
my $xp_oper = XML::LibXML::XPathExpression->new('./itdOperator/name');
- if ( $self->{lines} ) {
- return @{ $self->{lines} };
- }
-
for my $e ( $self->{tree}->findnodes($xp_element) ) {
my $e_info = ( $e->findnodes($xp_info) )[0];
@@ -376,6 +384,10 @@ sub results {
my ($self) = @_;
my @results;
+ if ( $self->{results} ) {
+ return @{ $self->{results} };
+ }
+
if ( not $self->{tree} ) {
return;
}
@@ -394,10 +406,6 @@ sub results {
my $xp_next_route
= XML::LibXML::XPathExpression->new('./itdOnwardStopSeq/itdPoint');
- if ( $self->{results} ) {
- return @{ $self->{results} };
- }
-
$self->lines;
for my $e ( $self->{tree}->findnodes($xp_element) ) {