From 6dabe27e6e73c18988f3bff2a34f23d038708ca0 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 22 Sep 2020 20:52:04 +0200 Subject: train details: proper error message --- lib/DBInfoscreen/Controller/Stationboard.pm | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm index 9efe0c3..2013669 100644 --- a/lib/DBInfoscreen/Controller/Stationboard.pm +++ b/lib/DBInfoscreen/Controller/Stationboard.pm @@ -260,10 +260,12 @@ sub handle_request { $opt{with_related} = 1; } - if ($self->param('train')) { + if ( $self->param('train') ) { + # request results from five minutes ago to avoid train details suddenly # becoming unavailable when its scheduled departure is reached. - $opt{datetime} = DateTime->now(time_zone => 'Europe/Berlin')->subtract(minutes => 20); + $opt{datetime} = DateTime->now( time_zone => 'Europe/Berlin' ) + ->subtract( minutes => 20 ); $opt{lookahead} = 200; } @@ -661,14 +663,18 @@ sub train_details { $self->stash( title => 'DBF' ); $self->stash( version => $dbf_version ); - $opt{datetime} = DateTime->now(time_zone => 'Europe/Berlin')->subtract(minutes => 20); + $opt{datetime} = DateTime->now( time_zone => 'Europe/Berlin' ) + ->subtract( minutes => 20 ); $opt{lookahead} = 200; my $data = get_results_for( 'iris', $station, %opt ); my $errstr = $data->{errstr}; if ( not @{ $data->{results} } ) { - $self->handle_no_results( 'iris', $station, $errstr ); + $self->render( + 'landingpage', + error => "Keine Abfahrt von $train_no in $station gefunden", + ); return; } @@ -676,8 +682,10 @@ sub train_details { = grep { result_is_train( $_, $train_no ) } @{ $data->{results} }; if ( not $result ) { - $self->handle_no_results( 'iris', $station, - "Zug $train_no nicht gefunden" ); + $self->render( + 'landingpage', + error => "Keine Abfahrt von $train_no in $station gefunden", + ); return; } -- cgit v1.2.3