summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/DBInfoscreen/Helper/Marudor.pm8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/DBInfoscreen/Helper/Marudor.pm b/lib/DBInfoscreen/Helper/Marudor.pm
index 91b34e3..cdc90f4 100644
--- a/lib/DBInfoscreen/Helper/Marudor.pm
+++ b/lib/DBInfoscreen/Helper/Marudor.pm
@@ -34,11 +34,13 @@ sub get_json_p {
my $promise = Mojo::Promise->new;
if ( my $content = $cache->thaw($url) ) {
+ $self->{log}->debug("marudor->get_json_p($url): cached");
+ if ( $content->{error} ) {
+ return $promise->reject( $content->{error} );
+ }
return $promise->resolve($content);
}
- $self->{log}->debug("get_json_p($url)");
-
$self->{user_agent}->request_timeout(5)->get_p( $url => $self->{header} )
->then(
sub {
@@ -48,6 +50,7 @@ sub get_json_p {
$self->{log}->debug(
"marudor->get_json_p($url): HTTP $err->{code} $err->{message}"
);
+ $cache->freeze( $url, { error => $err->{message} } );
$promise->reject(
"GET $url returned HTTP $err->{code} $err->{message}");
return;
@@ -72,6 +75,7 @@ sub get_json_p {
sub {
my ($err) = @_;
$self->{log}->debug("marudor->get_json_p($url): $err");
+ $cache->freeze( $url, { error => $err } );
$promise->reject($err);
return;
}