summaryrefslogtreecommitdiff
path: root/lib/DBInfoscreen
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2020-01-07 18:29:04 +0100
committerDaniel Friesel <daniel.friesel@uos.de>2020-01-07 18:29:04 +0100
commit1b43f08155fc7244b7ee231aaee4c20ee35f2066 (patch)
treead85fe268935c8892748ea0961e214e5316c8fd7 /lib/DBInfoscreen
parentcd4e1246ca33b7f0056be36a640bc2a7340a6667 (diff)
handle UserAgent timeouts gracefully
Diffstat (limited to 'lib/DBInfoscreen')
-rw-r--r--lib/DBInfoscreen/Controller/Stationboard.pm27
1 files changed, 20 insertions, 7 deletions
diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm
index 9f0bd31..797cde9 100644
--- a/lib/DBInfoscreen/Controller/Stationboard.pm
+++ b/lib/DBInfoscreen/Controller/Stationboard.pm
@@ -142,10 +142,14 @@ sub get_hafas_trip_id {
}
$ua->request_timeout(2);
- my $res
- = $ua->get(
- $url => { 'User-Agent' => "dbf.finalrewind.org/${dbf_version}" } )
- ->result;
+ my $res = eval {
+ $ua->get(
+ $url => { 'User-Agent' => "dbf.finalrewind.org/${dbf_version}" } )
+ ->result;
+ };
+ if ($@) {
+ return;
+ }
if ( $res->is_error ) {
return;
}
@@ -182,8 +186,11 @@ sub check_wagonorder {
}
$ua->request_timeout(2);
- my $res = $ua->head($url)->result;
+ my $res = eval { $ua->head($url)->result };
+ if ($@) {
+ return;
+ }
if ( $res->is_error ) {
$cache->set( $url, 'n' );
return;
@@ -201,8 +208,11 @@ sub hafas_json_req {
return $content;
}
- my $res = $ua->get($url)->result;
+ my $res = eval { $ua->get($url)->result };
+ if ($@) {
+ return;
+ }
if ( $res->is_error ) {
return;
}
@@ -228,8 +238,11 @@ sub hafas_xml_req {
return $content;
}
- my $res = $ua->get($url)->result;
+ my $res = eval { $ua->get($url)->result };
+ if ($@) {
+ return;
+ }
if ( $res->is_error ) {
$cache->freeze( $url, {} );
return;