summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-09-08 11:49:44 +0200
committerDaniel Friesel <derf@finalrewind.org>2018-09-08 11:49:44 +0200
commita13eaa989f5d93b9b7816a9c819821d79f7eb54f (patch)
treef36f9a850a7037d51b81b1e8d9a771f1aa86c09f
parent8f8a8df7e0b836d372fcfebe202ccc9ff8709f96 (diff)
Catch LibXML parser errors
-rw-r--r--lib/Travel/Status/DE/IRIS.pm11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Travel/Status/DE/IRIS.pm b/lib/Travel/Status/DE/IRIS.pm
index f9a05ee..efb080d 100644
--- a/lib/Travel/Status/DE/IRIS.pm
+++ b/lib/Travel/Status/DE/IRIS.pm
@@ -31,7 +31,7 @@ sub new {
developer_mode => $opt{developer_mode},
iris_base => $opt{iris_base}
// 'http://iris.noncd.db.de/iris-tts/timetable',
- lookahead => $opt{lookahead} // ( 2 * 60 ),
+ lookahead => $opt{lookahead} // ( 2 * 60 ),
lookbehind => $opt{lookbehind} // ( 0 * 60 ),
main_cache => $opt{main_cache},
rt_cache => $opt{realtime_cache},
@@ -131,7 +131,7 @@ sub new {
}
@{ $self->{results} } = grep {
- my $d = ( $_->departure // $_->arrival );
+ my $d = ( $_->departure // $_->arrival );
my $sd = $_->sched_departure // $_->sched_arrival // $d;
$d = $d->subtract_datetime( $self->{datetime} );
$sd = $sd->subtract_datetime( $self->{datetime} );
@@ -215,7 +215,12 @@ sub get_station {
}
}
- my $xml_st = XML::LibXML->load_xml( string => $raw );
+ my $xml_st;
+ eval { $xml_st = XML::LibXML->load_xml( string => $raw ) };
+ if ($@) {
+ $self->{errstr} = "Parse error: $@";
+ return;
+ }
my $station_node = ( $xml_st->findnodes('//station') )[0];