From 506b66a84c4ec39d69c74f9a42d4f100909ac4a0 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 29 Apr 2015 17:39:40 +0200 Subject: add support for timeouts, do not die if XML tree parsing failed --- lib/Travel/Status/DE/EFA.pm | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'lib/Travel/Status') diff --git a/lib/Travel/Status/DE/EFA.pm b/lib/Travel/Status/DE/EFA.pm index a895ca6..f8ea9f7 100644 --- a/lib/Travel/Status/DE/EFA.pm +++ b/lib/Travel/Status/DE/EFA.pm @@ -114,7 +114,9 @@ sub new { $self->{xml} = $response->decoded_content; - $self->{tree} = XML::LibXML->load_xml( string => $self->{xml}, ); + $self->{tree} = XML::LibXML->load_xml( + string => $self->{xml}, + ); #say $self->{tree}->toString(1); @@ -126,9 +128,13 @@ sub new { sub new_from_xml { my ( $class, %opt ) = @_; - my $self = { xml => $opt{xml}, }; + my $self = { + xml => $opt{xml}, + }; - $self->{tree} = XML::LibXML->load_xml( string => $self->{xml}, ); + $self->{tree} = XML::LibXML->load_xml( + string => $self->{xml}, + ); return bless( $self, $class ); } @@ -277,6 +283,10 @@ sub results { my ($self) = @_; my @results; + if ( not $self->{tree} ) { + return; + } + my $xp_element = XML::LibXML::XPathExpression->new('//itdDeparture'); my $xp_date = XML::LibXML::XPathExpression->new('./itdDateTime/itdDate'); -- cgit v1.2.3