From e89ed392bb06abf8cc36d31b3b033ef2b2abf57b Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 30 Jan 2022 11:28:30 +0100 Subject: Gracefully handle failed realtime data requests --- lib/Travel/Status/DE/IRIS.pm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib/Travel/Status') diff --git a/lib/Travel/Status/DE/IRIS.pm b/lib/Travel/Status/DE/IRIS.pm index 1be5808..79e96d9 100644 --- a/lib/Travel/Status/DE/IRIS.pm +++ b/lib/Travel/Status/DE/IRIS.pm @@ -135,10 +135,20 @@ sub new_p { for my $eva (@related_stations) { push( @realtime_reqs, $self->get_realtime_p( $eva, $dt_req ) ); } - return $self->{promise}->all(@realtime_reqs); + return $self->{promise}->all_settled(@realtime_reqs); } )->then( sub { + my @realtime_results = @_; + + for my $realtime_result (@realtime_results) { + if ( $realtime_result->{status} eq 'rejected' ) { + $self->{warnstr} //= q{}; + $self->{warnstr} + .= "Realtime data request failed: $realtime_result->{reason}. "; + } + } + $self->postprocess_results; $promise->resolve($self); return; -- cgit v1.2.3