From bb89800fd5b970c5b12ecfe2ad2318874c97793f Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 20 Mar 2021 13:23:33 +0100 Subject: HAFAS, Marudor: Handle empty responses --- lib/DBInfoscreen/Helper/HAFAS.pm | 6 ++++++ lib/DBInfoscreen/Helper/Marudor.pm | 7 +++++++ 2 files changed, 13 insertions(+) (limited to 'lib/DBInfoscreen') diff --git a/lib/DBInfoscreen/Helper/HAFAS.pm b/lib/DBInfoscreen/Helper/HAFAS.pm index b97248d..2b8172e 100644 --- a/lib/DBInfoscreen/Helper/HAFAS.pm +++ b/lib/DBInfoscreen/Helper/HAFAS.pm @@ -62,6 +62,12 @@ sub get_json_p { my $json = decode_json($body); + if ( not $json ) { + $self->{log}->debug("hafas->get_json_p($url): empty response"); + $promise->reject("GET $url returned empty response"); + return; + } + $cache->freeze( $url, $json ); $promise->resolve($json); diff --git a/lib/DBInfoscreen/Helper/Marudor.pm b/lib/DBInfoscreen/Helper/Marudor.pm index 21083a7..dad9dc7 100644 --- a/lib/DBInfoscreen/Helper/Marudor.pm +++ b/lib/DBInfoscreen/Helper/Marudor.pm @@ -55,6 +55,13 @@ sub get_json_p { my $res = $tx->res->json; + if ( not $res ) { + $self->{log} + ->debug("marudor->get_json_p($url): empty response"); + $promise->reject("GET $url returned empty response"); + return; + } + $cache->freeze( $url, $res ); $promise->resolve($res); -- cgit v1.2.3